BookmarkSubscribeRSS Feed
Josh
Calcite | Level 5
Ok SYMPUT I use all the time and in preference to SELECT INTO : in PROC SQL but SYMGET I just don't get it. In a data step what does x=symget('macrovar') achieve that x="&macrovar" does not?
3 REPLIES 3
WillDobson
Calcite | Level 5
Hi Josh,

You can use a datastep variable to determine which macro variable is retreived using symget:
[pre]
data this;
do x = 1 to 3; output;
call symput(put(x,words5.),x);
end;
run;

data that;
set this;
y = symget(put(x,words5.));
run;
[/pre]
The other main feature I use it for is that it can retreive a macro variable which has been set by call symput from within the same step:
[pre]
%symdel me;
data also;
call symput("me","mememe");
put 'Value of &me: ' "&me."; *Not found;
tst = symget("me");
put 'Value of &me: ' tst; *Found;
run;
[/pre]
Regards,
-- Will Message was edited by: WillDobson
data_null__
Jade | Level 19
Short answer: Symget is executable.

Plus check out symgetN to create a numeric value from a macro variable value.
chang_y_chung_hotmail_com
Obsidian | Level 7
Interesting that you mentioned the symget function. I remember vividly this sas-l thread about the certification exam but also about the not-well-known-back-then (and now either, it seems) symget function. 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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