## Help using Base SAS procedures

Solved
Contributor
Posts: 36

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!

Accepted Solutions
Solution
‎12-19-2012 01:41 PM
Super User
Posts: 8,125

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;

All Replies
Posts: 3,167

A slice of your sample data would help to promote more concrete and prompt responses.

Haikuo

Frequent Contributor
Posts: 86

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;

Solution
‎12-19-2012 01:41 PM
Super User
Posts: 8,125

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;

Contributor
Posts: 36