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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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