Date: Tue, 23 Dec 2003 15:56:58 -0700
Reply-To: Kenneth Moody <KennethMoody@FIRSTHEALTH.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Kenneth Moody <KennethMoody@FIRSTHEALTH.COM>
Subject: Re: gluing single quote to mvar contents using %LET
Content-Type: text/plain; charset=us-ascii
Mark,
Here's one method which may work (not sure about elegance):
1 %let mvar = a','b','c;
2 %let sq = %nrbquote(');
3 %let qvar = &sq.&mvar.&sq;
4 %put mvar is >&mvar.< qvar is >&qvar.<;
mvar is >a','b','c< qvar is >'a','b','c'<
An alternative, if you have a macro variable consisting of a space
delimited list is the macro sqlist posted on this forum a couple of
years ago:
%macro sqlist( list );
%* Single quote a list;
%* Posted on SAS-L 1-3-2001 by Peter Crawford from a Feb/Mar 2000
post by Paul Dorfman;
%* Input is a space delimited word list;
%* Output is a comma delimited list of quoted words;
%nrbquote(')%sysfunc( tranwrd( %Qsysfunc( compbl( &LIST ) ), %str( ),
%str(', ')))%nrbquote(')
%mend sqlist ;
Ken
>>> "Terjeson, Mark" <TERJEM@DSHS.WA.GOV> 12/23/03 02:05PM >>>
Hi All,
re: Looking for a more eligant syntax
to glue a single quote on the front
and back of macro variable contents.
I've done not so pretty methods, but am
missing a more eligant and concise way.
e.g.
%* original macro variable contents ;
%* which is missing leading&trailing ;
%* single quote characters ;
%let mvar=a','b','c;
%let mvar='&mvar.'; * obviously is not going to resolve ;
%put &mvar;
would like results to be: 'a','b','c'
Thanks in advance,
Mark
|