10-25-2017 11:36 AM
I have a question on setting a check point within the SAS code. This check point could decide if later procedures will run or stop.
The code has 10 input tables: Table1, Table2, ..., Table10.
Later procedures will run if Table1 through Table10 they all have observations (not empty). Later procedure will stop if any one of Table1 through Table10 is empty.
I know the following code could check whether the table is empty or not for 1 table:
Proc Sql noprint; Select * from Table1; Quit; put *&sqlobs*; if &sqlobs > 0 then do; ... else do; end;
How could I apply similar procedure to 10 tables? Is there any simple way?
10-25-2017 11:53 PM
You can use the DICTIONARY feature of proc sql, specifically dictionary.tables. Lets say you want to examine all datasets whose name begins with 'X' in the work library:
proc sql noprint; select case when min(nobs)>0 then 'CONTINUE' else 'STOP' end into :status from dictionary.tables where libname='WORK' and memname like 'X%'; quit; %put &=status; %if &status=CONTINUE %then %do; ... ... %end;
10-27-2017 01:05 AM