BookmarkSubscribeRSS Feed
hspears
Calcite | Level 5

Hello,

 

I do not understand all the ways to correctly call Macro variables. Is there a guide of when you need to put a period after the &Macro and when you do not? I am thinking in both the context of quoted strings like a Title statement or in naming a data set in a data step. 

 

Thank you! 

 

 

3 REPLIES 3
PaigeMiller
Diamond | Level 26

A period is required to end the name of a macro variable, usually when appending text to the value of the macro variable. No period is required if there is a separator (like a space or other character that cannot be in a macro variable name).

 

So no period is required here

x = &macrovarname+7;

but it's also not wrong to put a period here.

 

A period is required here

x = &macrovarname.2;

so the 2 is appended to the value of &macrovarname.

--
Paige Miller
Tom
Super User Tom
Super User

You only need to period if the next character in your program could be part of the macro variable name.  Valid characters for names are letters, digits and underscore.

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 547 views
  • 0 likes
  • 4 in conversation