assign return value to macro functions
/* To check if a variable {vnam} exists on a dataset {dsnam} /
/ Return a non-zero number if variable exists */
%macro var_exists(dsnam, vnam);
%local dsid vnum;
%let vnum = 0;
%let dsid = %sysfunc(open(&dsnam));
%if &dsid ne 0 %then %do;
%let vnum = %sysfunc(varnum(&dsid, &vnam));
%let dsid = %sysfunc(close(&dsid));
%end;
&vnum
%mend var_exists;