05-02-2018 02:22 AM - last edited on 05-02-2018 04:04 AM by RW9
The following SAS program is submitted:
X = 0;
do Index = 1 to 5 by 2;
X = Index;
how the answer is coming x=5 and Index=7? can anybody explain me what is happening step by step?
05-02-2018 02:57 AM
Here you we assigned X=0 and index=1
it increments 1 ,3 ,5 and 7 . In index=5 condition is true then X is 5
and again do loop by 2 value is added (index=7) and condition is falls
so X=5 and index=7
05-02-2018 10:51 AM
Perhaps if you look at the resulting data set done this way it will help.
This creates an output record for each time the loop executes.
data WORK.LOOP; X = 0; do Index = 1 to 5 by 2; X = Index; output; end; run;