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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.