SAS中文论坛

标题: 求助:关于call execute [打印本页]

作者: shiyiming    时间: 2008-11-13 12:57
标题: 求助:关于call execute
将一个文件夹下(路径: f:\aa)的excel全部导入sas。
源程序:
filename indata pipe 'dir f:\aa/b';
data file_list;
length fname $50.;
infile indata truncover;
call symput ('num_files',_n_);
input fname $50.;
prefixname=tranwrd(fname, '.xls' , '');
call symput ('out',prefixname);
call symput ('in',fname);
run;

data _null_;
set file_list;
by prefixname;
if first.prefixname then call execute('proc import out='||prefixname||'
   datafile="f:\aa\'||prefixname||'"
   dbms=excel replace;
   run;');
run;

log的错误提示:
datafile="f:\aa\a1
2   +
                                                                                          "
dbms=excel replace;
ERROR: File Name value exceeds maximum length of 201 characters.

请高手帮我分析分析阿。要是能告诉我call execute()的语法就更好啊,授人以渔阿,谢谢
作者: shiyiming    时间: 2008-11-14 00:18
标题: Re: 求助:关于call execute
you're doing perfect except that [i:3a1zwxos]prefixname[/i:3a1zwxos] has too many trailing blanks so you'll have to trim it.
作者: shiyiming    时间: 2008-11-14 08:19
标题: Re: 求助:关于call execute
谢谢回复!~
这样改过之后还是不行啊
filename indata pipe 'dir f:\aa/b';
data file_list;
length fname $50.;
infile indata truncover;
call symput ('num_files',_n_);
input fname $50.;
prefixname=tranwrd(fname, '.xls' , '');
call symput ('out',prefixname);
call symput ('in',fname);
run;

data _null_;
set file_list;
by prefixname;
if first.prefixname then call execute('proc import out='||prefixname||'
datafile="f:\aa\trim('||prefixname||')"  
dbms=excel replace;
run;');
run;
作者: shiyiming    时间: 2008-11-14 13:28
标题: Re: 求助:关于call execute
try
[code:14wxkpvp]
if first.prefixname then call execute('proc import out=' || prefixname || ' datafile="f:\aa\' || trim(prefixname) || '" dbms=excel replace; run;');
[/code:14wxkpvp]
作者: shiyiming    时间: 2008-11-14 13:46
标题: Re: 求助:关于call execute
成功了,谢谢,能告诉我,call execute的语法吗,谢谢!~            <!-- e --><a href="mailto:luijb@163.com">luijb@163.com</a><!-- e -->
作者: shiyiming    时间: 2008-11-14 23:18
标题: Re: 求助:关于call execute
you may enclose any # of valid SAS statements as a string within a CALL EXECUTE statement, and the enclosed statements get executed only [u:hjdfgr5c]after[/u:hjdfgr5c] the current DATA step (to which your CALL EXECUTE statement belong).
There're many examples, [url=http&#58;//www&#46;google&#46;com/search?hl=en&amp;q=sas+call+execute:hjdfgr5c]google[/url:hjdfgr5c] is your friend.
IMHO, a SAS program appears similar to a web page, while macros are server-side scripts, DATA steps and Procedures are client-side scripts, and CALL EXECUTE just resembles response.write() in ASP, print in PHP, or out.println() in JSP. it's super flexible, but the source code w/ CALL EXECUTE is hard to understand. i would try my best to avoid it in my program.
作者: shiyiming    时间: 2008-11-15 12:40
标题: Re: 求助:关于call execute
收到,非常感谢!~




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2