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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 27304 views
  • 5 likes
  • 3 in conversation