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 (February 2012, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 22 Feb 2012 14:46:13 -0600
Reply-To:   Joe Matise <snoopy369@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Joe Matise <snoopy369@GMAIL.COM>
Subject:   Re: Anybody got a %commify macro?
Comments:   To: "Pardee, Roy" <pardee.r@ghc.org>
In-Reply-To:   <587F57B26FAA8246A81D10D251EB8AB4029FAA234B@EXCH07.GHCMASTER.GHC.ORG>
Content-Type:   text/plain; charset=ISO-8859-1

%macro commify(your_macro_var); %sysfunc(tranwrd(&your_macro_var,%str( ),%str(, ))); %mend commify;

%let my_var=%commify(bibbity bobbity boo) ; %put &my_var;

Assuming you can rely on having one space between words and no extra spaces.

-Joe

On Wed, Feb 22, 2012 at 2:40 PM, Pardee, Roy <pardee.r@ghc.org> wrote:

> I need a macro that will insert commas between the words of a string. > Before I set about writing that, I thought I'd ask if anybody on this list > has one already they're willing to share? Googling has not availed me. > > I want to be able to say, e.g., > > %let my_var = %commify(bibbity bobbity boo) ; > > And have &my_var = bibbity, bobbity, boo. > > Input will be individual variable names, if that helps. > > Anybody got something like that handy? > > Thanks! > > -Roy > > Roy Pardee | DATA WRANGLER > Group Health Research Institute > > PHONE 360-447-8773 | 206-287-2078 > E-MAIL pardee.r@ghc.org > www.grouphealthresearch.org > > GHC Confidentiality Statement > > This message and any attached files might contain confidential information > protected by federal and state law. The information is intended only for > the use of the individual(s) or entities originally named as addressees. > The improper disclosure of such information may be subject to civil or > criminal penalties. If this message reached you in error, please contact > the sender and destroy this message. Disclosing, copying, forwarding, or > distributing the information by unauthorized individuals or entities is > strictly prohibited by law. >


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