BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have month-end data files which contain the rating system of borrowers in that particular month. Rating system of borrowers may change by month.

Now, I want to check which borrower with 3 or more rating system changes in the past 12 months.

I will combine all the month-end files and then sort by timekey, borrid. Then, what should i do? Can any one show me the SAS scripts? Many thanks!!!!!!!!
2 REPLIES 2
Patrick
Opal | Level 21
HTH
Patrick

data have;
do timekey=1 to 12;
do borrid=1 to 10;
if ceil(ranuni(0)*5)=5 then output;
end;
end;
run;

proc sort data=have;
by borrid timekey;
run;

data want;
set have;
by borrid timekey;
N_change+1;
if last.borrid then do;
if N_change>=3 then output;
N_change=0;
end;
run;

proc print data=want;
run;
deleted_user
Not applicable
if your data files are in "borrower" order, you need no sort. Just use by processing and an interleaving SET of the 12 files.
data threes ;
changes = -1 ;
do until( last.borrower ) ; * work through the data for a borrower;
set file1 file2 ..... file12 ; * you need all 12 names not dots ;
by borrower ;
last_rating_system= lag( rating_system ) ;
if first.borrower then last_rating_system= ' ' ;
if rating_system ne last_rating_system then changes + 1 ;
end;
if changes ge 3 ;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1008 views
  • 0 likes
  • 2 in conversation