BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SAS_John
Obsidian | Level 7

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?

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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 _

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

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 _

--
Paige Miller
SAS_John
Obsidian | Level 7

Thank PaigeMiller! much appreciated.

 

Best,

 

John

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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