BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Anna_Guo
Calcite | Level 5


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!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

4 REPLIES 4
Haikuo
Onyx | Level 15

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

Haikuo

bnarang
Calcite | Level 5

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;

Tom
Super User Tom
Super User

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;

Anna_Guo
Calcite | Level 5


Tom, Thank you very much. It works perfectly.

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 4 replies
  • 863 views
  • 3 likes
  • 4 in conversation