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;
posted @ 2023-08-30 08:55  helloyuen  阅读(6)  评论(0编辑  收藏  举报