data want;
do week=1 to 100;
day=week+1;
llc=day+;
ulc=day+;
end;
run;
Dear,
I need help in DO iterative code. I need to skip every third number and create two variables for each row by adding different numbers.
eg; for 1,2,3 combination I need to skip 3 and create llc and ulc variables for 1,2.
For row 1, i need to calculate llc=day+2 and ulc=day+5.
For row 2, i need to calculate llc=day+3 and ulc=day+6
I need to repeat above for all three set combinations. Please suggest. Thank you
output needed
week day llc ulc
1 2 4 7
2 3 6 9
4 5 7 10
5 6 9 12
Here one option
data want;
do week=1 to 100;
rem=mod(week,3);
if rem = 0 then continue;
day=week+1;
llc=day+1+rem;
ulc=day+4+rem;
output;
end;
drop rem;
run;
Did you mean something like this?
data want;
week=0;
day=1;
do until(week>10);
do inc=1 to 3;
week+1;
day+1;
llc=day+1+inc;
ulc=day+4+inc;
if inc<3 then output;
else week+-1;
end;
end;
drop inc;
run;
Obs week day llc ulc 1 1 2 4 7 2 2 3 6 9 3 3 5 7 10 4 4 6 9 12 5 5 8 10 13 6 6 9 12 15 7 7 11 13 16 8 8 12 15 18 9 9 14 16 19 10 10 15 18 21 11 11 17 19 22 12 12 18 21 24
Here one option
data want;
do week=1 to 100;
rem=mod(week,3);
if rem = 0 then continue;
day=week+1;
llc=day+1+rem;
ulc=day+4+rem;
output;
end;
drop rem;
run;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.