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 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 20 Feb 2004 11:19:47 -0500
Reply-To:     "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject:      Re: a question of macro
Comments: cc: miranda <mixiao@UCLA.EDU>
Content-Type: text/plain; charset="us-ascii"

> From: miranda [mailto:mixiao@UCLA.EDU] > option MPRINT MLOGIC SYMBOLGEN; > %macro Channame(name,node); > data _null_; > > if length("&name.")=7 then call > symput('stname',trim(left(compress(substr("&name.",1,4))))||"&node."); > else if length("&name.")=6 then call > symput('stname',trim(left(compress(substr("&name.",1,3))))||"&node."); > put "&stname."; > run; > %mend Channame; > %Channame(ARSW003,5); > %Channame(ASI003,10); > %Channame(AEF003,10); > > I hope the macro variable &stname. can be resolved to > ARSW5, ASI10 and AEF10. there is something wrong with my > codes, Please let me know what's your suggestion.

It is not necessary to run a data step to assign a value to a macro variable.

%macro Channame(name,node,StName = .); %If %length("&name.")=6 %then %Let StName = %substr(&Name.,1,3)&Node.; %else %If %length("&name.")=7 %then %Let StName = %substr(&Name.,1,4)&Node.; %put &stname.; %mend Channame;

I wonder if this works: %macro Channame(name,node,StName = .,Column=1); %If %length("&name.")=6 %then %Let Column=3; %else %If %length("&name.")=7 %then %Let Column=4; %Let StName = %substr(&Name.,1,&Column.)&Node.; %put &stname.; %mend Channame;

what's your purpose in doing this? StName is %local to the macro.

Ron Fehd the macro maven CDC Atlanta GA USA --> cheerful provider of UNTESTED SAS code from the Clue?Gee!Wrx <--

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