BookmarkSubscribeRSS Feed
Ansileran
Calcite | Level 5
Hi !

I'm trying to use a macro variable as part of a column name. The main problem is that the query builder encloses the column name in simple quotes, and therefore doesn't recognise the macro variable as such.

Here is what I have :

a macro variable defined by a user prompt (which can be used, I checked) : YEAR
and a column name which should be : "AGE_&YEAR" => AGE_2010, AGE_2011...

If I try this, SAS writes the following code : AS '"AGE_&YEAR"'... Is there a way to remove those simple quotes ? Other than writing a program, I mean...

Thanks !
1 REPLY 1
Patrick
Opal | Level 21
Hi

Tried out what you've described. The code generated looks actually like:
'"AGE_&YEAR"'n

This 'n' means that the string is interpreted as literal. Seems that SAS R&D was quite thoughtful in allowing us to define all kind of variable names but didn't anticipate your use case.
Haven't found any option like "treat variable names as literals" which could be unchecked so I believe the current version of EG's query builder doesn't allow you what you try to do.

You could define the variable label this way though by passing the macro var without quotes: AGE_&YEAR

HTH
Patrick

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
  • 1 reply
  • 987 views
  • 0 likes
  • 2 in conversation