Hi Kannan, One way is to have another macro test if a data set exists, and if so, then count the number of observations. Then, if the conditions are met, call the macro that does the PROC. I've taken your data and simplified it a bit (using PROC MEANS, and creating a 0 obs data set).... Data merchant_1; Input Item $ sales_amount; Datalines; shoe 50 fan 100 TV 500 SOFA 1000 ; run; Data merchant_999; Input item $ sales_amount; Datalines; LOCK 50 PC 100 MUG 500 LAPTOP 1000 ; run; /* create data set with 0 obs...*/ data MERCHANT_2; set MERCHANT_1; if sales_amount < 1; run; %macro TAB; proc means data=MERCHANT_&seq ; var sales_amount; title1 "STATISTICS from data set MERCHANT_&seq"; run; %mend TAB; %macro REPORT(seq); %if %sysfunc(exist(MERCHANT_&seq)) %then %do; %let dsid = %sysfunc(open(MERCHANT_&seq)); *open the data set ; %let NumObs = %sysfunc(attrn(&dsid,nlobs)); *count number of logical observations ; %let RC = %sysfunc(close(&Dsid)); %IF &NUMOBS > 0 %then %TAB; %ELSE %PUT "DATA SET MERCHANT_&seq HAS 0 OBS!!"; %end; %ELSE %put "DATA SET MERCHANT_&seq DOES NOT EXIST!!"; %mend REPORT; %report(1) %report(2) %report(3) %report(999) Hope this helps..
... View more