5# MyLoveSas
我也没能成功运行这程序, 加不加空格都一样?
400 %let extfile = xls ;
401 %let dirpath= C:\test\ ;
402 filename dirpipe pipe 'dir &dirpath.\*..&extfile./b';
403
404 data _info ;
405 length filepath $120. ;
402 filename dirpipe pipe 'dir &dirpath.\*..&extfile./b';
--
49
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS
release. Inserting white space between a quoted string and the succeeding
identifier is recommended.
406 infile terms pad missover end=eof;
407 input @1 filename $20.;
408 filepath = "&dirpath" || trim(filename) ;
409 filename = scan( filename , 1 ) ;
410 call symput('filepath'
-
49
410! || left(_n_),filepath);
NOTE 49-169: The meaning of an identifier after a quoted string may change in a future SAS
release. Inserting white space between a quoted string and the succeeding
identifier is recommended.
411 call symput('filename' || left(_n_),filename);
412 if eof then call symput('nfiles',left(_n_));
413 run;
414
415 %macro importdbf ;
416 %do i = 1 %to &nfiles ;
417 proc import datafile = "&&filepath&i" out = %trim(&&filename&i) dbms = &extfile ;
418 run ;
419 %end ;
420
421 proc sql noprint ;
422 select filename into : datasets separated by ' ' from _info ;
423 quit ;
424
425 data all ;
426 set &datasets ;
427 run ;
428 %mend importdbf ;
429
430 %importdbf ;