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.
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.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.