I know what is going on .
data have;
input TOTAL_NOTE_BALANCE_15YR ;
cards;
45746
43473
.
.
.
43011
;
run;
data want;
do until(not missing(TOTAL_NOTE_BALANCE_15YR ) or last1);
set have end=last1;
end;
NEW_TOTAL_NOTE_BALANCE_15YR =TOTAL_NOTE_BALANCE_15YR ;
do until(not missing(TOTAL_NOTE_BALANCE_15YR ) or last2);
set have end=last2;
output;
end;
run;
When _n_ eq 1 :
the first do until will rolling here
45746 <---
43473
.
.
.
43011
;
assign 45746 to new variable.
the second do until will output this obs , so new variable retain 45746 and export to WANT dataset.
When _n_ eq 2 :
the first do until will rolling here
45746
43473 <---
.
.
.
43011
;
assign 43473 to new variable.
the second do until will output this obs , so new variable retain 43473 and export to WANT dataset.
When _n_ eq 3 :
the first do until will rolling here
45746
43473
.
.
.
43011 <---
;
assign 43011 to new variable.
the second do until will output the following 4 obs utill 43011 , so new variable retain 43011 and export to WANT dataset with these four obs .
etc...........
Thanks, Xia. So it is kind of nested DoW loop?
Yes. It is DOW skill has been mentioned by many people and many times.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.