Date: Mon, 15 Dec 2008 01:01:47 +0000 toby dunn "SAS(r) Discussion" toby dunn Re: Macro Do Loop for Discrete Values To: dyanosky@kennesaw.edu <200812150016.mBEBoP8Q031734@malibu.cc.uga.edu> text/plain; charset="iso-8859-1"

The technique you are looking for is:

%Macro Loop( Num= ) ; %Local I

%Do I = 1 %To %Eval( %SysFunc( CountC( &Num , %Str( ) ) ) + 1 ) ; %Put %Scan( &Num , &I , %Str( ) ) ; %End ;

%Mend Loop ;

%Loop( Num = 1.5 2 3 5 )

Toby Dunn

"Don't bail. The best gold is at the bottom of barrels of crap." Randy Pausch

"Be prepared. Luck is where preparation meets opportunity." Randy Pausch

> Date: Sun, 14 Dec 2008 19:16:14 -0500 > From: dyanosky@KENNESAW.EDU > Subject: Macro Do Loop for Discrete Values > To: SAS-L@LISTSERV.UGA.EDU > > Hello, > > I need to run a macro-valued do loop using discrete values. I found the > following code (paraphrased) on the list-serv, but it does not seem to > work in my case because one of my values contains a decimal. Any idea on > how to make this work? > > %LET VARIANCE = %STR(1.5 2 3 5); > > %MACRO SIM(ITER=); > > %LOCAL I TKN1; > > %LET I = 1; > %LET TKN1 = %SCAN(&VARIANCE, &I); > %DO %WHILE (%LENGTH(&TKN1) NE 0); > > > DATA D; > I = &I; > TOKEN = &TKN1; > RUN; > > PROC APPEND BASE=RESULTS DATA=D FORCE; > RUN; QUIT; > > %LET I = %EVAL(&I + 1); > %LET TKN1 = %SCAN(&VARIANCE, &I); > > %END; > > %MEND; > > %SIM(ITER=1) > > PROC PRINT DATA=RESULTS; > RUN; QUIT; > > Thanks, > > Daniel _________________________________________________________________ Send e-mail faster without improving your typing skills. http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_speed_122008

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