BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8

Hi Team,

I was reading a paper on Do loops and Do loops  in Macros

http://analytics.ncsu.edu/sesug/2010/FF01.Woodruff.pdf

On page 18 it says you  can use this method

only when you intervals to be calculated that are a factor of 10;

for .1 divide by 10,

for .2 divide by 5 and

for .5 divide by 2.  (if we do this we get the values from 5.0,5.5 6.0 so on) We actually wanted 10.0 10.5 11.0 11.5 etc????????

%Macro Test ;

%Do I = %SysEvalF( 1 * 10 ) %To %SysEvalF( 2 * 10 ) ;

%Put I = %sysEvalF( &I / 10 ) ;

%End ;

%Mend ;

%Test

I = 1

I = 1.1

I = 1.2

I = 1.3

I = 1.4

I = 1.5

I = 1.6

I = 1.7

I = 1.8

I = 1.9

I = 2

In the above code we have used the %SysEvalF for the Start, Stop and in the %PUT to increment the values from 1

to 2 by 0.1. This works solely because the math in the Start and Stop values will create the needed number of

iterations and the %SysEvalF in the %PUT will manipulate the values to create the desired output.

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

Karun: Not sure what your question is.  You could get the values you want with (although the %SysEvalF is only really needed for the 2nd of the two %put statements):

%Macro Test ;

%Do I = %SysEvalF( 1 * 10 ) %To %SysEvalF( 2 * 10 ) ;

%Put I = %sysEvalF( &I  ) ;

%Put I = %sysEvalF( &I + .5 ) ;

%End ;

%Mend ;

%Test

View solution in original post

1 REPLY 1
art297
Opal | Level 21

Karun: Not sure what your question is.  You could get the values you want with (although the %SysEvalF is only really needed for the 2nd of the two %put statements):

%Macro Test ;

%Do I = %SysEvalF( 1 * 10 ) %To %SysEvalF( 2 * 10 ) ;

%Put I = %sysEvalF( &I  ) ;

%Put I = %sysEvalF( &I + .5 ) ;

%End ;

%Mend ;

%Test

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 2136 views
  • 0 likes
  • 2 in conversation