1st Way:-
%macro test;
%local InDat Exist NumObs;
%let InDat = MM_IP;
%let Exist = No;
%let NumObs = 0;
DATA null;
set sashelp.vmember(where = (libname = "WORK" and memtype = "DATA"));
if upcase(memname) = "%upcase(Retail_summ1)" then call symput("Exist",'Yes');
RUN;
%if &Exist = Yes %then %do;
%let DSNId = %sysfunc(open(Retail_summ1));
%let DSObs = %sysfunc(attrn(&DSNId.,nobs));
%let rc = %sysfunc(close(&DSNId.));
%let NumObs = &DSObs ; %end;
2nd Way:-
%let Exist = No;
%let NumObs = 0;
%if %sysfunc(exist(&InDat)) %then %let Exist = Yes;
%if &Exist = Yes %then %do;
PROC SQL noprint;
select * from &InDat;
QUIT;
%let NumObs = &SQLObs;
%end;
3rd Way:-
%put EXIST: &Exist;
%put NUMBER OF OBS: &NumObs;
%if &Exist = No or &NumObs = 0 %then %do;
DATA pval; prob = .;
RUN;
%end;
%mend;
%put &NumObs &Exist;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.