BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

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;
SAS_inquisitive
Lapis Lazuli | Level 10
Hi Xia, How two DoW-loop is working here? Can you explain little bit? Thanks !
Ksharp
Super User

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...........

 

 

SAS_inquisitive
Lapis Lazuli | Level 10

Thanks, Xia.  So it is kind of nested DoW loop?

Ksharp
Super User

Yes. It is DOW skill has been mentioned by many people and many times.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 19 replies
  • 4347 views
  • 2 likes
  • 8 in conversation