李真LZ 发表于 2017-5-29 14:27
提示是这样子的:
Spreadsheet isn't from Excel V5 or later. Please open it in Excel and Save as V ...
- filename indata pipe 'dir "c:\documents and settings\administrator\桌面\test\*.xls" /b/s';
- data files;
- infile indata truncover;
- input char $200. ;
- char1=scan(scan(char,-1,'\'),1,'.');
- run;
- /*宏变量n,表示*.xls文件个数,用于宏程序循环判断*/
- proc sql noprint;
- select count(char) into : n from files;
- run;
- quit;
- %macro import_xls_files;
- %do i=1 %to &n;
- /************************************/
- /*把每个具体文件名的路径存入宏变量char*/
- data _null_;
- set files;
- length char2 $20.;
- if _n_=&i then do;
- call symput('char',char);
- call symput('char1',char1);
- end;
- run;
- %put &char2;
- /************************************/
- proc import out=test_&char1
- datafile= "&char"
- dbms=excel4 replace;
- /* getnames=yes;*/
- run;
- /************************************/
- %end;
- %mend import_xls_files;
- %import_xls_files