遍历字符列表以导入xlsx文件SAS

时间:2020-09-14 15:43:31

标签: sas

嗨,我有一个简单的问题,但是我发现的所有响应都非常复杂,我在宏中有一个要引用的文件名列表,以便在此处导入所有文件,< / p>

 %let y20 = Jan20 Feb20;  
 %macro boucle_doCC(in);
    
    proc import datafile ="&rep.\&in..xlsx"
                out=&in
                dbms=xlsx replace; 
                getnames=yes;
    run;
    %end;
    %mend boucle_doCC; 

我知道在proc导入之前我需要执行do循环,但是我不知道该怎么做,您能帮忙吗?

1 个答案:

答案 0 :(得分:0)

data files;
   input file $;
   datalines;
Jan20
Feb20
;

%macro boucle_doCC(in=,rep=/*repository here*/);
    proc import datafile ="&rep.\&in..xlsx"
    out=&in
    dbms=xlsx 
    replace; 
    getnames=yes;
run;
%mend boucle_doCC; 

data _null_;
    set files;
    call symputx('file',file);
    call execute('%boucle_doCC(in='||file||');');
run;