BookmarkSubscribeRSS Feed
Arun_shSAS
Fluorite | Level 6

 

%let C=test;



Data a;

input x $;

cards;

LI 

GI 

H&C

;



Proc sql noprint;

select x into: test2 separated by "," from a;

quit;

 

I want macro variable test2 to be resolved as LI,GI,H&C

 

3 REPLIES 3
Astounding
PROC Star
There will likely be headaches down the road, but you should be able to use %SUPERQ. For example:

%put %superq(test2);
Patrick
Opal | Level 21

@Arun_shSAS 

Looks like a case for %SUPERQ() or SYMGET().

%let C=test;

data a;
  input x $;
  cards;
LI 
GI 
H&C
;

proc sql noprint;
  select x into :test2 separated by "," from a;
quit;

%put Option_1: %superq(test2);

data _null_;
  Option_2=symget("test2");
  put Option_2=;
run;
Kurt_Bremser
Super User

The first question that comes to mind is "what for"?

Macro variables are the worst place for keeping data, SAS provides datasets as storage for that.

 

And if you need reference data for, say, where conditions, it's always better to use a defined key of some kind and not free-form text, which is the worst you can use for such things.

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