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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 612 views
  • 0 likes
  • 4 in conversation