DATA Step, Macro, Functions and more

how to create macro variable with ''?

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,636
Accepted Solution

how to create macro variable with ''?

After I ran the code below, macro variable &mnew=a,b,c.

How can I get &mnew=’a’,’b’,’c’ by modifing my code.

Thanks - Linlin

data have;

  input c_id $;

  cards;

  a

  b

  c

   ;

data _null_;

  set have end=last;;

  length new $ 30;

retain new;

new=catx(',',new,c_id);

if last then

call symputx('mnew',new);

run;

%put &mnew;


Accepted Solutions
Solution
‎03-20-2012 09:25 AM
Super User
Super User
Posts: 7,054

Re: how to create macro variable with ''?

If you can use double quote characters instead of single quote then use the QUOTE() function.

new=catx(',',new,quote(trim(c_id)));

If you need to use single quotes then

new=catx(',',new,"'"||trim(c_id)||"'");

View solution in original post


All Replies
Solution
‎03-20-2012 09:25 AM
Super User
Super User
Posts: 7,054

Re: how to create macro variable with ''?

If you can use double quote characters instead of single quote then use the QUOTE() function.

new=catx(',',new,quote(trim(c_id)));

If you need to use single quotes then

new=catx(',',new,"'"||trim(c_id)||"'");
Super Contributor
Posts: 1,636

Re: how to create macro variable with ''?

Hi Tom,

Thank you very much!!! - Linlin

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 141 views
  • 0 likes
  • 2 in conversation