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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 619 views
  • 0 likes
  • 2 in conversation