SAS 多重导入

SAS Multiple import

有什么方法可以在 SAS 中对 excel 电子表格进行多进程导入?见下文。我想做类似的事情:*.xlsx。

    proc import datafile= "/gpfs_nonhsm02/corrections/users/id/CB10/IMPORT1/BANK053.xlsx" dbms=xlsx out=OUT.IMPORT_DS4 replace;
    sheet="CIG OPT OUT";
    getnames=YES;
run;


proc import datafile= "/gpfs_nonhsm02/corrections/users/id/CB10/IMPORT1/BANK111.xlsx" dbms=xlsx out=OUT.IMPORT_DS5 replace;
    sheet="CIG OPT OUT";
    getnames=YES;
run;



proc import datafile= "/gpfs_nonhsm02/corrections/users/id/CB10/IMPORT1/BANK121.xlsx" dbms=xlsx out=OUT.IMPORT_DS6 replace;
    sheet="CIG OPT OUT";
    getnames=YES;
run;

使用 LIBNAME 代替 PROC COPY。

libname myXLSX XLSX "/gpfs_nonhsm02/corrections/users/id/CB10/IMPORT1/BANK111.xlsx";

proc copy in=myXLSX out=WORK;
select <list of data sets here>;
run;

在 txt 中导入时可以使用 *,但对于 .xlsx,您可以使用宏功能。下面是一个示例,希望对您有所帮助。 我创建了两个示例。

例一

/* function for the import of specific tables. */
%macro manytables(table, out);
    proc import datafile= "\gpfs_nonhsm02\corrections\users\id\CB10\IMPORT1\&table..xlsx" dbms=xlsx out=&out. replace;
        sheet="CIG OPT OUT";
        getnames=YES;
    run;
%mend;
%manytables(BANK053, IMPORT_DS4);
%manytables(BANK111, IMPORT_DS5);
%manytables(BANK121, IMPORT_DS6);

例二。 按数字顺序导入所有目录。

/* initializing the variable */
%let BD = 0;

/* function that read your tables */
%macro manytables(table, out);
    proc import datafile= "\gpfs_nonhsm02\corrections\users\id\CB10\IMPORT1\&table..xlsx" dbms=xlsx out=&out. replace;
        sheet="CIG OPT OUT";
        getnames=YES;
    run;
%mend;

/* function that performs the import of all tables */
%macro list;
    %do %while (&BD. < 111);
          %manytables(BANK&BD., IMPORT_DS&BD.);
         %let BD = %eval(&BD. + 1);
    %end;
%MEND list;
%list;

祝你好运!!!