Macro Variable call in a macro

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

Macro Variable call in a macro

Hi, 

 

I am rewriteing a sas program based on other people's work. Do not understand macro variable call in a macro. Can somebody help me out? Thanks!

%macro medianrange(trt=,var=,ord=,subord=,param=,varfmt=);

proc means data=adsl nway maxdec=2 noprint;
  where trt01pn=&trt.;
  var &var.;
  format &var. &varfmt.;
  output out=stat&var._ 
           min = min median = median max = max n=n mean=mean std=sd /*q1=q1 q3=q3*/;
run;
....

The macro variable "var &var." is called in a macro. Why put "." after the &var?


Accepted Solutions
Solution
‎06-03-2017 09:44 PM
Trusted Advisor
Posts: 1,783

Re: Macro Variable call in a macro

[ Edited ]

The period after &var is optional in this situation. It indicates the end of the macro variable name (in other words, the macro variable name is the three letters var). This might be needed in other situations, for example if you want to use &var followed by other text, so you want the value of &var followed by the text string _method2, you would use &var._method2. The period after &var in the OUTPUT statement is required, in order to indicate the end of the ename of the macro variable; and so the output data set is the name STAT followed by the value of &var followed by _

View solution in original post


All Replies
Solution
‎06-03-2017 09:44 PM
Trusted Advisor
Posts: 1,783

Re: Macro Variable call in a macro

[ Edited ]

The period after &var is optional in this situation. It indicates the end of the macro variable name (in other words, the macro variable name is the three letters var). This might be needed in other situations, for example if you want to use &var followed by other text, so you want the value of &var followed by the text string _method2, you would use &var._method2. The period after &var in the OUTPUT statement is required, in order to indicate the end of the ename of the macro variable; and so the output data set is the name STAT followed by the value of &var followed by _

Contributor
Posts: 20

Re: Macro Variable call in a macro

Thank PaigeMiller! much appreciated.

 

Best,

 

John

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 174 views
  • 1 like
  • 2 in conversation