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 (June 2004, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 Jun 2004 13:29:54 -0400
Reply-To:     Bruce Johnson <bjohnson@SOLUCIENT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Bruce Johnson <bjohnson@SOLUCIENT.COM>
Subject:      Re: %DO Loop With Alpha Index???
Comments: To: Anthony J Pitruzzello <apitruzzello@CPS.K12.IL.US>
Content-Type: text/plain; charset="us-ascii"

Anthony,

Try this code.

proc format; value numalph 1='A' 2='B' 3='C' 4='D' ; run; data test(drop=_i); X=0; Z='STEM'; do _i= 1 to 4; i=put(_i,numalph.); X = X + 10; Y = Z||I; output; end; run; proc print data=test; run;

The SAS System 12:26 Monday, June 7, 2004 3

Obs X Z i Y

1 10 STEM A STEMA 2 20 STEM B STEMB 3 30 STEM C STEMC 4 40 STEM D STEMD ________________________________ Bruce A. Johnson bjohnson@solucient.com

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Anthony J Pitruzzello Sent: Monday, June 07, 2004 10:07 AM To: SAS-L@LISTSERV.UGA.EDU Subject: %DO Loop With Alpha Index???

Good morning (CST),

Does anyone know if there is a way to execute a %DO loop with a character index? For example, this regular SAS code: DATA F1; X=0; Z='STEM'; DO I = 'A','B','C'; X = X + 10; Y = Z||I; OUTPUT; END; RUN;

Produces this result:

X Z I Y

10 STEM A STEMA 20 STEM B STEMB 30 STEM C STEMC

I would like to be able to run something like this within a macro, namely., a %DO loop with a character index. I'm not a macro expert, but I suspect macro sees alphas as literals rather than as values on an ordinal scale. I was hoping there was some alpha counterpart to the %EVAL function, but I haven't found anything. Is there a way to do this? This message is a private communication. It may contain information that is confidential and legally protected from disclosure. If you are not an intended recipient, please do not read, copy or use this message or any attachments, and do not disclose them to others. Please notify the sender of the delivery error by replying to this message, and then delete it and any attachments from your system. Thank you, Solucient LLC (rev eXclaimer 2x)


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