LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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
Comments: To: TERJEM@DSHS.WA.GOV
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


Back to: Top of message | Previous page | Main SAS-L page