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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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