BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MKhandelwal
Fluorite | Level 6
Hi,

I have a macro variable dep_var as

[pre] %let dep_var=yld syld myld; [/pre]
I want a new macro variable as say
[pre]new_dep='yld syld myld' [/pre]
i.e I want to cocatenate the text of my macro variable dep_var with single quotes.

Thanks.
1 ACCEPTED SOLUTION

Accepted Solutions
russt_sas
SAS Employee

There are 2 ways to accomplish this task.

 

%let dep_var=yld syld myld;

 

Method 1:

%let new_var2=%unquote(%str(%'&dep_var%'));

 

Method 2 (If running SAS 9.4 or greater):

%let new_var3=%tslit(&dep_var);

 

View solution in original post

2 REPLIES 2
data_null__
Jade | Level 19
%str(%') is needed. You may need to unquote the value, now or later.

[pre]
927 %let dep_var=yld syld myld;
928 %let new_var1=%str(%')&dep_var.%str(%');
929 %let new_var2=%unquote(%str(%')&dep_var.%str(%'));
930
931 %put _user_;
GLOBAL NEW_VAR2 'yld syld myld'
GLOBAL NEW_VAR1 yld syld myld
GLOBAL DEP_VAR yld syld myld
[/pre]
russt_sas
SAS Employee

There are 2 ways to accomplish this task.

 

%let dep_var=yld syld myld;

 

Method 1:

%let new_var2=%unquote(%str(%'&dep_var%'));

 

Method 2 (If running SAS 9.4 or greater):

%let new_var3=%tslit(&dep_var);

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 27600 views
  • 5 likes
  • 3 in conversation