If you have a dataset, the subsequent program's execuation depends on whether this dataset exists or have at least one observation.
%let dsid = %sysfunc(open(demo_ds));
%if &dsid ^= 0 %then %do;
%let nobs = %sysfunc(attrn(&dsid, nlobs));
%let rc = %sysfunc(close(&dsid));
%end;
%if &dsid ^= 0 & nobs ^= 0 %then ....