data a;
b = 1; c = 2; output;
run;
%macro existsVariable(lib =, ds =, var =);
%local dsid check rc;
%let dsid = %sysfunc(open(&lib..&ds.));
%let check = %sysfunc(varnum(&dsid., &var.));
%let rc = %sysfunc(close(&dsid.));
%if &check. = 0 %then %do;
0
%end; %else %do;
1
%end;
%mend existsVariable;
%put %existsVariable(lib = work, ds = a, var = b);
1# elliott828