10-04-2017 08:42 PM
I have 2 data sets (Current and Prev month).
I need to compare the 2 datasets no. of observations and if the current month data set has more no. of records then I need to run or call a macro?
How do I achieve that?
10-04-2017 09:21 PM
proc sql noprint; select nobs into: curr from dictionary.tables where upcase(libname)="MYLIB" and upcase(memname)='MY_CURR'; select nobs into: PREV from dictionary.tables where upcase(libname)="MYLIB" and upcase(memname)='MY_PREV'; QUIT; %macro HasMore; %if %eval(&prev<curr) %then %do; %MyMacro; %end; %mend %HasMore;
Hope this helps.
10-04-2017 11:53 PM
data _null_; if NOBS1 ne NOBS2 then call execute('%mymacro;'); set TABLE1 nobs=NOBS1; set TABLE2 nobs=NOBS2; stop; run;
Simple since there is no macro language, and fast since we don't use the dictionary.
10-05-2017 02:51 PM - edited 10-05-2017 02:54 PM
Thanks Chris it did the job for me....
Any specific reason why the if logic before reading the data sets?
10-05-2017 03:35 PM - edited 10-05-2017 10:03 PM
If you put it after the SET statements and one of the data sets is empty, it will never be executed.