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 (April 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 13 Apr 2007 13:10:00 -0400
Reply-To:     Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:      Re: A SIMPLE MACRO PROBLEM AS A CONTINUATION OF UNCLEANED DATASET
Comments: To: Toby Dunn <tobydunn@HOTMAIL.COM>

On Fri, 13 Apr 2007 16:49:27 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:

>Sasi , > >Uhhh sorry to tell you are wrong. > >As a cheesy example (Ian dont get after the design it is only here to >illistrate that it can be done): > >%Macro Chg( Var = ) ; >%If &Var Eq A %Then %Do ; > 1 >%End ; >%Else %If &Var Eq B %Then %Do ; > 2 >%End ; >%Else %If &Var Eq C %Then %Do ; > 3 >%End ; >%Mend Chg ; > > >Data _Null_ ; >Do X = 'A' , 'B' , 'C' ; > Y = Resolve( '%Chg( Var = ' || Put( X , 8. -L ) || ' ) ' ) ; > Put X= Y= ; >End ; >Run ;

Hi, I think that toby meant something like below. X is a character variable, which does not need to be put (actually, you can't). On the other hand, the resolve function returns a character string, which should be input since the intention seems to be creating a *numeric* variable y. HTH. Cheers, Chang

%macro abc2num(var); %*-- returns 1 for A, 2 for B, 3 for C, otherwise 0 --*; %*-- note: case sensitive --*; %*;%index(ABC,%superq(var)) %mend abc2num;

data _null_; do x = "A", "B", "C", "D"; y = input(resolve(catt('%abc2num(',x,')')), best.); put x= y=; end; run; /* on log x=A y=1 x=B y=2 x=C y=3 x=D y=0 */


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