Hi All ... I am trying to execute a Data Step based on the availability of a signal file. The SAS Data Step should execute after the file is available at a location, the SAS program should check the availablity of file for every 10-15 and for Max time of 3 hours and if the file is available then execute the DATASTEP. The SAS programs will be called in Cron's Please suggest me on this. /*DATE VARIABLES FOR THE CURRENT ORPHAN RUN...BASED ON THE SIGNAL FILE*/ Data _Null_; Rept_date= INTNX('DAY',"&SYSDATE."d,0); Mnth=Month(Rept_date); Year=Year(Rept_date); Days=Day(Rept_date); if Mnth<=9 Then do; Mnth_N=Put(Mnth,Z2.); End; Else Mnth_N=Mnth; if Days<=9 Then do; Days_N=Put(Days,Z2.); End; Else Days_N=Days; Put Days_N; NewDte= Compress(Cats(Year,Mnth_N,Days_N),'/'); Call Symput ('New_dte',Newdte); Run; %put Days====>&new_dte.; %LET myfilerf=<"FILE PATH........">; %PUT File=====>>> &myfilerf.; %LET fname= %trim(SALES_&new_Dte.).txt; %PUT Filename=====>>> &fname.; %let Entity= %scan(&myfilerf.,-1); /*Name of the Entity or region for SALES extracted from the File path */ %put Entity======>> &Entity.; %global counter max; %let counter=0; %let max=60; /* Minutes To Check */ options Nomlogic Nomprint Nosymbolgen; ******************************************************************************; *** RUN JOB ******************************************************************; ******************************************************************************; %MACRO FILE_WAIT(); %if (%sysfunc(fileexist(&myfilerf.\&fname.))=1 )% then %do; %PUT NOTE: "SIGNAL FILES EXISTS, ORPHAN DATA PROCESSING...."; *INCLUDE THE PROGRAM TO BE EXECUTED IF THE ABOVE CONDTION IS TRUE; %end; /*1*/ %else %do; %PUT WARNING: WAITING ORPHAN SIGNAL FILES: &myfilerf.\&fname.; %do %until (%sysfunc(fileexist(&myfilerf.\&fname.))=1 or (&counter+0 > &max+0)); Data _Null_; Sleep= SLEEP(5,1); Run; %put MAX====>>> &max.; %let counter=%eval(&counter.+1); %put COUNTER===>>>>> &counter.; %if &counter+0 > &max+0 %then %goto EXIT; %if (%sysfunc(fileexist(&myfilerf.\&fname.))=1 ) %then %do; %put Note: Orphan File Processing...; %end; *2; %end; *3; *** Stop program if time out ***; %end; %EXIT: %mend FILE_WAIT; %FILE_WAIT();
... View more