【问题标题】:loop through char list to import xlsx files SAS遍历字符列表以导入 xlsx 文件 SAS
【发布时间】:2020-09-14 15:43:31
【问题描述】:

您好,我有一个简单的问题,但我发现的所有回复都非常复杂,我有一个文件名列表,我想在宏中引用这些文件名,以便导入所有文件,这里是我所在的位置

 %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 循环,但我不知道该怎么做,你能帮忙吗?

【问题讨论】:

标签: sas


【解决方案1】:
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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多