온라인으로 매크로를 사용하여 여러 개의 Excel 파일을 단일 sas 데이터 세트로 가져옵니다. 그리고 그것은 아주 잘 작동합니다. 그러나 하나의 변수 "플레이트"를 추가하여 각 Excel 파일을 지정하려고합니다. 다음 매크로는 다음과 같습니다 가져 오기 후 추가 전의 변수 추가
%macro MultImp(dir=,range=,out=,n=);
%let rc=%str(%'dir %")&dir.%str(\%" /A-D/B/ON%');
filename myfiles pipe %unquote(&rc);
data list;
length fname $256.;
infile myfiles truncover;
input myfiles $100.;
fname=quote(upcase(cats("&dir",'\',myfiles)));
out="&out";
drop myfiles;
call execute('
%do i=1 %to &n.;
proc import dbms=xlsx out= _test
datafile= '||fname||' replace ;
range="&range";
run;
data _test;
set _test;
plate=&i;
run;
proc append data=_test base='||out||' force; run;
proc delete data=_test; run;
%end;
');
run;
filename myfiles clear;
%mend;
%MultImp(dir=U:\test,range=summary$.D10:Y200,out=test,n=30);
가 나는이
call execute
의 내부 루프를 수행하고
proc import
후 작은 데이터 단계를 실행할 수 있지만
proc append
전에 썼다. 하지만 작동하지 않습니다. 아무도 데이터 세트를 추가하기 전에이 변수를 어떻게 추가 할 수 있는지 알 수 있습니까? 미리 감사드립니다.
우수! 대단히 감사합니다 !!! – lxcfuji