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.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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