Desktop productivity for business analysts and programmers

Urgent: About SAS scripts

Reply
N/A
Posts: 0

Urgent: About SAS scripts

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!!!!!!!!
Respected Advisor
Posts: 3,841

Re: Urgent: About SAS scripts

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;
N/A
Posts: 0

Re: Urgent: About SAS scripts

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;
Ask a Question
Discussion stats
  • 2 replies
  • 88 views
  • 0 likes
  • 2 in conversation