Hi everyone, I can't figure out why this code doesn't work. Specificially, the &varnum doesn't get resolved.
options symbolgen;
options mprint;
options mlogic;
%macro count_vars(dataset);
%local varnum;
proc sql;
select count(*) into : varnum
from dictionary.columns
where memname=upcase("&dataset");
quit;
%mend count_vars;
%count_vars(Mf_hist_holdings_all)
%put varnum = &varnum;
The ERROR message is like below:
"MLOGIC(COUNT_VARS): Ending execution.
WARNING: Apparent symbolic reference VARNUM not resolved.
421 %put varnum = &varnum;
varnum = &varnum"
By the way, I don't understand why this code doesn't run.
%macro count_vars(dataset, varnum);
proc sql;
select count(*) into : varnum
from dictionary.columns
where memname=upcase("&dataset");
quit;
%mend count_vars;
%count_vars(Mf_hist_holdings_all, varnum)
The reason is I don't want to remember that varnum is a variable that contains the number of variables in a dataset. Imagine I have 100 macros and everytime I run one such macro, I have to open the source code and check what name that variable has, i.e. here varnum. So when I clean a dataset, I can do the following
%global myvars;
%count_vars(mydataset, myvars)
INSTEAD OF openning the source code and checking that the name is varnum and only then can I put "varnum" as an argument to the macro %count_vars.
Can somebody please advise?
Message was edited by: smilingmelbourne
Message was edited by: smilingmelbourne