사이트맵  |  Contact Us
 
홈 > SAS Stories > SAS 활용 노하우
특정 디렉토리 밑에 있는 모든 sas프로그램을 수행해야 할때 2010.06.04
MYSAS 5208 0
http://www.mysas.co.kr/sas_club/d_freeboard.asp?b_no=1393&gotopage=6&con=subject&keyword=&cmd=content&bd_no=04&gubun=

때론 특정 디렉토리 밑에 있는 모든 sas프로그램을 수행해야 할때도 있죠. 이렇게 함 해보세요.

This code uses macro logic to open a directory and determine the number of files in the directory. The code then determines if the extension of the file is .SAS. If it is, the the file is read in using a %INCLUDE to execute the file.

This code uses macro and an %INCLUDE to execute all the .SAS files in a given directory.
%macro readsas(dir);                                                                                                                    
  %local fileref rc did dnum dmem memname filename didc;                                                                                
  %let rc=%sysfunc(filename(fileref,&dir));                                                                                             
  %let did=%sysfunc(dopen(&fileref));                                                                                                   
  %if &did=0 %then %do;                                                                                                                 
    %put ERROR: Directory does not exist;                                                                                               
      %put ERROR: The macro will terminate;                                                                                             
    %return;                                                                                                                            
  %end;                                                                                                                                 
  %let dnum=%sysfunc(dnum(&did));                                                                                                       
  %do dmem=1 %to &dnum;                                                                                                                 
    %let memname=%qsysfunc(dread(&did,&dmem));                                                                                          
      %if %qupcase(%qscan(&memname,-1,.)) = SAS %then %do;                                                                              
        %let filename=%scan(&memname,1,.);                                                                                              
        %inc "&dir.&filename..sas";                                                                                                     
      %end;                                                                                                                             
  %end;                                                                                                                                 
  %let didc=%sysfunc(dclose(&did));                                                                                                     
  %let rc=%sysfunc(filename(fileref));                                                                                                  
%mend;                                                                                                                                  
/* The directory path must end with a '\' */                                                                                                                                        
%readsas(c:\)

 

Type: Sample
Date Modified: 2009-12-15 10:36:19
Date Created: 2009-12-14 10:49:21

Operating System and Release Information

Product Family Product Host SAS Release
Starting Ending
SAS System Base SAS Microsoft Windows Server 2003 Enterprise Edition 8.2 TS2M0  
Microsoft Windows Server 2003 Datacenter Edition 8.2 TS2M0  
Microsoft Windows 2000 Professional 8.2 TS2M0  
Microsoft Windows NT Workstation 8.2 TS2M0  
Microsoft Windows 2000 Server 8.2 TS2M0  
Microsoft Windows 2000 Datacenter Server 8.2 TS2M0  
Microsoft Windows 95/98 8.2 TS2M0  
Microsoft Windows 2000 Advanced Server 8.2 TS2M0  
OS/2 8.2 TS2M0  
Microsoft Windows Server 2003 Standard Edition 8.2 TS2M0  
Microsoft Windows XP Professional 8.2 TS2M0  
Windows Millennium Edition (Me) 8.2 TS2M0

 
 
휴대폰 번호
휴대폰 인증번호
 
 &SYSJOBID 를 이용하면 SAS 작업의 process id 를 알아 내실 수 있답니다.
 [질문,펌]감마분포로 중심극한 정리