BookmarkSubscribeRSS Feed
TanviG
Fluorite | Level 6

Hi,

 

Here is the explaination of my dataset. Data contains 62 variables. One is unique key as account id and 60 variables are some monthly recovery amounts. the last variable is Total Loss. I want to know all default accounts monthly basis. For this, I created one array of recoveries which is the cumulative sum of months. I am facing problem in creating this array. 

 

data test;
set recovery;
array month{60} nm_1-nm_60;
array recovery{60);
do i=1 to 60;
if _n_=1 then do;
Recovery(i)=month(i);
end;
else do;
Recovery(i)= Sum(month(i),Recovery(i-1));
end;
end;
run;

 

after this I want to check the condition in do loop

data test;

set recovery;

do i=1 to 60;

If Recovery(i) < total_loss then output(i);

end;

run;

 

Can you please help me with the code.

 

1 REPLY 1
PGStats
Opal | Level 21

Make SAS retain the values of recovery array elements between observations by giving an initial value to the array

 

array recovery{60} (60*0);

 

You must also define the array in your second datastep. You don't say what the final dataset is supposed to be. Now, it will contain the whole recovery array, repeated for every element that is less than total_loss.

PG

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 631 views
  • 0 likes
  • 2 in conversation