How to check if a sas dataset was created or not

/*CHECK IF COVPARMS is CREATED*//*CHECK IF COVPARMS is CREATED*/
%macro checkds(dsn);
%if %sysfunc(exist(&dsn)) %then %do;
proc print data = &dsn;run;
data HLM_OR_NOT;value="YES_HLM";run;
%end;
%else %do;
data covparms;CovParm="NoCov";run;
data HLM_OR_NOT;value="NO_HLM ";run;
%end;
%mend checkds;
/* Invoke the macro, pass a non-existent data set name to test */
%checkds(work.covparms);
data _null_;set hlm_or_not;
call symput ("hlm_or_not",value);
run;
%put &hlm_or_not;
/*CHECK IF COVPARMS is CREATED*//*CHECK IF COVPARMS is CREATED*/

Leave a Reply