%macro checkNobs(dsn); proc sql noprint; select Nobs into :ObsCount from dictionary.tables where trim(libname)||"."||memname="%upcase(&dsn)"; quit; %if &ObsCount > 0 %then %do; proc print data=&dsn(obs=10); title1 "A few observations from &dsn"; run; %end; %else %do; data _null_; file print notitles; put "There are no observations in &dsn"; run; %end; %mend checkNobs; %checkNobs(SASHELP.CLASS) *Valid data set; %checkNobs(SASHELP.DPLOG) *Empty data set;