BookmarkSubscribeRSS Feed

[파일읽기] 디렉토리에 저장되어 있는 동일한 형태의 파일 읽기

Started ‎06-15-2020 by
Modified ‎06-15-2020 by
Views 185

FTP에서 내려 받은 복수의 파일들을 읽기 위하여 사용되는 프로그램.

 

Sample 41880: Read all files from a directory and create separate SAS® data sets with unique names

http://support.sas.com/kb/41/880.html

 

filename DIRLIST pipe 'dir "C:\_today\file*.csv" /b ';

 

data dirlist ;

   infile dirlist lrecl=200 truncover;

   input file_name $100.;

run;

 

data _null_;

   set dirlist end=end;

   count+1;

   call symputx('read'||put(count,4.-l),cats('c:\_today\',file_name));

   call symputx('dset'||put(count,4.-l),scan(file_name,1,'.'));

   if end then call symputx('max',count);

run;

 

options mprint symbolgen;

%macro readin;

   %do i=1 %to &max;

 

      data &&dset&i;

         infile "&&read&i" lrecl=1000 truncover dsd;

         input var1 $ var2 $ var3 $;

       run;

 

   %end;

%mend readin;

 

%readin;

 

* 참고 : FTP 서버에서 ftp 명령어를 사용하여서 파일 내려 받기

 : http://cafe.daum.net/statsas/3F8j/374

 

Version history
Last update:
‎06-15-2020 02:55 AM
Updated by:
Contributors

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

Article Labels
Article Tags