data eq1;
input ID y x z w;
cards;
1 1 30 . 25
3 1 . 45 .
4 1 48 25 56
;
run;
%macro genmod(method,missper);
proc genmod data = &&method&missper;
class y(ref='0') id;
model y= x z w/ dist=bin link=logit pred covb;
repeated subject=id / type=ar(1) PRINTMLE;
ods output ParameterEstimates=&&method.lgs&missper;
run;
%MEND genmod;
%genmod(eq,1);
Hello,
I am writing some MACRO. I know for above code example ( eq=method and missper=1 ), if I want to write 'eq1', I could use &&method&missper. But I want to know more complex writing way. For 'eqlgs1', I use &&method.lgs&missper. what about 'leq.gs1' or 'leq_1gs'? something like those. Any other way to write eqlgs1?
Thanks
Here are a few examples from what you asked about:
%put will write the resolved text to the log.
When you use multiple &'s this is indirect referencing. Documentation: http://go.documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=mcrolref&docsetTarget=n0vl7...
See below:
%let method=eq; %let missper=1; %let method1=Hello; /*eq1*/ %put &method&missper; /*eqlgs1*/ %put &method.lgs&missper; /*leq.gs1*/ %put l&method..gs&missper; /*leq_1gs*/ %put l&method._&missper.gs; /*When there are double ampersands in front of a macro variable, they are resolved to one ampersand. Then the next macro variable is resolved. Finally the macro variable is rescanned and resolved. &&method&misper -> &method1 -> Hello */ %put &&method&missper;
Use the macro without the proc genmod, just put a %put into it, so you can experiment until you get it right.
You may want to test your macro coding with Options Mprint symbolgen; (turn off with Options Nomprint Nosymbolgen;).
Check the rules for macro variable concatenation and the very significant difference between &var1.&var2 and &&var1&var2.
Here are a few examples from what you asked about:
%put will write the resolved text to the log.
When you use multiple &'s this is indirect referencing. Documentation: http://go.documentation.sas.com/?cdcId=pgmmvacdc&cdcVersion=9.4&docsetId=mcrolref&docsetTarget=n0vl7...
See below:
%let method=eq; %let missper=1; %let method1=Hello; /*eq1*/ %put &method&missper; /*eqlgs1*/ %put &method.lgs&missper; /*leq.gs1*/ %put l&method..gs&missper; /*leq_1gs*/ %put l&method._&missper.gs; /*When there are double ampersands in front of a macro variable, they are resolved to one ampersand. Then the next macro variable is resolved. Finally the macro variable is rescanned and resolved. &&method&misper -> &method1 -> Hello */ %put &&method&missper;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.