I need to asign a numeric rating for each bond ( my sample size is very large). There are 4 main credit agencies giving a letter credit rating for certain year/company ( this rating may change). I attached a table that include the numeric rating for each corresponding letter rating of each agency .
Thanks!
Why not just merge the data with your attached table? You will probably want to reformat the data so that you have one row per credit agency and rating letter grade pair.
data cr ;
infile 'Credit_ratings.csv' dlm=',' dsd truncover ;
input raten @;
do agency = 'SPR', 'MR', 'FRR', 'DPR' ;
input ratech $ @ ;
if ratech ne ' ' then output ;
end;
run;
proc sql noprint ;
create table want as
select a.*,b.raten
from have a left join cr b
on a.agency = b.agency
and a.ratech = b.ratech
;
quit;
A slice of your sample data would help to promote more concrete and prompt responses.
Haikuo
You can Create a custom format with Proc format and apply the same in your data.
For example:
proc format;
value $rate
'AAA' = 1
'AA+' = 2
'A+' = 3
'BBB' = 4
;
run;
Data want;
set have;
format variable-name rate.;
run;
Why not just merge the data with your attached table? You will probably want to reformat the data so that you have one row per credit agency and rating letter grade pair.
data cr ;
infile 'Credit_ratings.csv' dlm=',' dsd truncover ;
input raten @;
do agency = 'SPR', 'MR', 'FRR', 'DPR' ;
input ratech $ @ ;
if ratech ne ' ' then output ;
end;
run;
proc sql noprint ;
create table want as
select a.*,b.raten
from have a left join cr b
on a.agency = b.agency
and a.ratech = b.ratech
;
quit;
Tom, Thank you very much. It works perfectly.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.