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 (July 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 15 Jul 2004 14:52:48 -0500
Reply-To:   "Dunn, Toby" <tdunn@TEA.STATE.TX.US>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Dunn, Toby" <tdunn@TEA.STATE.TX.US>
Subject:   Re: Change text in a macro variable
Comments:   To: Pat Moore <anpam@UAA.ALASKA.EDU>
Content-Type:   text/plain; charset="us-ascii"

Pat the following throws a warning but will get you what you want I think:

%let ay = 2001-2002;

%let ay2 = %sysfunc(compress(%substr(&ay,1,(%eval(%index(&ay,-)-1)))_ %substr(&ay,%eval(%index(&ay,-)+1),%length(&ay))));

%put &ay2;

HTH Toby Dunn

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Pat Moore Sent: Thursday, July 15, 2004 2:44 PM To: SAS-L@LISTSERV.UGA.EDU Subject: Change text in a macro variable

SAS Gurus,

I have a variable called ay which looks like this: 2001-2002. I want to use it as part of a filename, so I need to get rid of the hyphen or (preferably) replace the hyphen with an underline. I'm doing this in a macro, so I need a step that does something like this:

data &c&cno&(translate(&ay,'-','_')); set etc...

So that the macro creates a filename like:

data ART1022001_2002;

How does one accomplish this feat?

Pat Moore


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