|
6#
楼主 |
发表于 2004-5-18 20:36:56
|
只看该作者
Firstly,thanks for shiyiming & qkaiwei's help ,现把一个完整的程序放在这里,与大家共享:)
[code:fbb82]filename filein pipe 'dir d:\temp /b';
data _null_;
infile filein truncover end=last;
length f_name1 $ 60 ;
input f_name1 $ ;
i+1;
call symput('Fname'||trim(left(put(i,8.))),trim(left(f_name1)));
call symput('Pname'||trim(left(put(i,8.))),trim(left(f_name1)));
if last then call symput('total',trim(left(put(i,8.))));
run;
%MACRO Mult_Files(Out_set=);
%LOCAL i ;
%DO i = 1 %TO &total;
proc import datafile="d:\temp\&&Pname&i"
out=_temp
dbms=excel2000 replace;
getnames=yes;
sheet="sheet1";
data _temp ;
set _temp;
file = "&&Fname&i";
data &out_set ;
set &out_set _temp ;
run;
%END ;
data &out_set ;
set &out_set;
run;
%MEND Mult_Files ;
%mult_files(out_set=record) [/code:fbb82]
整个程序中会产生2个数据集,一个是最后需要的汇总数据集out_set,另外一个_temp则为临时数据集。
感觉上要是能采用proc sql 优化一下,直接生成最后所需要的汇总数据集就好了,不知可行否? |
|