macro variable with quotes

  • Follow


Hi everybody!

   I've spent too much time trying to solve this question.

I need a macrovariable with a list of arbitrary words separated by quotes, 
i.e something similar to: "a","b","c","d".

I'm doing:

%let l="a,b,c,d";
data _null_;
   call symput ("letters",trim(put(&l.,$100.)));
run;
%put &letters.;

And, obiously, I get:

a,b,c,d 

instead that I really want.

My question is: 
how can I transform the string "a,b,c,d" to another string with all the letters separated 
by quotes, i.e "a","b","c","d" ? 

I've tried with tranwrd and translate unsuccessfully.

Can somebody give me a hint?

Thanks a lot,

vinner21
0
Reply Vinner21 2/9/2011 7:42:11 AM

On Feb 9, 8:42=A0am, Vinner21 <vidalmargi...@hotmail.com> wrote:
> Hi everybody!
>
> =A0 =A0I've spent too much time trying to solve this question.
>
> I need a macrovariable with a list of arbitrary words separated by quotes=
,
> i.e something similar to: "a","b","c","d".
>
> I'm doing:
>
> %let l=3D"a,b,c,d";
> data _null_;
> =A0 =A0call symput ("letters",trim(put(&l.,$100.)));
> run;
> %put &letters.;
>
> And, obiously, I get:
>
> a,b,c,d
>
> instead that I really want.
>
> My question is:
> how can I transform the string "a,b,c,d" to another string with all the l=
etters separated
> by quotes, i.e "a","b","c","d" ?
>
> I've tried with tranwrd and translate unsuccessfully.
>
> Can somebody give me a hint?
>
> Thanks a lot,
>
> vinner21

4514  %let l=3D"a,b,c,d";
4515  %let str=3D%sysfunc(tranwrd(&l,%str(,),%str(", ")));
4516  %put str=3D&str;
str=3D"a", "b", "c", "d"
0
Reply RolandRB 2/9/2011 11:23:59 AM


1 Replies
301 Views

(page loaded in 0.037 seconds)

Similiar Articles:













7/26/2012 5:17:19 PM


Reply: