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

I am facing some issues in SAS Macro Variables.

 

I have a program in which my library name is a macro variable and the data set name may or may not be a macro variable.

 

something like this . >

 

&LIBRARY.SORTED,

 

or 

 

&LIBRARY.&DATA

 

now whenever I use it as &LIBRARY.SORTED, It resolves to SASHELPSORTED and considers it to be in work library.

 

what should I do to resolve it as SASHELP.SORTED

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

You should learn the full syntax for using a macro variable and Always use it in your code.  The form is:

&<macro variable name>.

 

Note the & before and the dot afterwards, this is the leading and terminating character, so when you use the dot it terminates the variable, and does not show in the generated text.  What your code should look like (and also note that coding all in upper case makes it harder to read):

&library..sorted

 

You will see the two dots, one to close the macro variable, the second is used to delimit library and dataset.

View solution in original post

4 REPLIES 4
Kurt_Bremser
Super User

Macro variable names muste be valid SAS names (letters, digits, underlines, must not start with a digit, max length 32). The dot cannot be used in a macro variable name; it is always used to mark the end of a macro variable name when it is referenced.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

You should learn the full syntax for using a macro variable and Always use it in your code.  The form is:

&<macro variable name>.

 

Note the & before and the dot afterwards, this is the leading and terminating character, so when you use the dot it terminates the variable, and does not show in the generated text.  What your code should look like (and also note that coding all in upper case makes it harder to read):

&library..sorted

 

You will see the two dots, one to close the macro variable, the second is used to delimit library and dataset.

DipeshGupta
Calcite | Level 5

ThankYou Very Much EveryOne. It worked. 🙂

Reeza
Super User
&LIBRARY..&DATA

You need two periods.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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