BookmarkSubscribeRSS Feed
Calcite | Level 5

Hello all,

I have tried to develop something through SAS PROC IML in order to calculate a Credit Rating Transition Matrix for a specific sample, considering the cohort and hazard rate approaches, and also some confidence levels using bootstrap. This website ( provides some specific examples regarding the "RTransprob" package which contains a set of functions used to automate commonly used methods to estimate migration matrices used in credit risk analysis. I'd like to do the same, however, through SAS instead of R. I have a SAS dataset containing the following attributes: CustomerId,Date,Rating,RatingNum.


I'm sending as an attached files:

a) Input_RatingTransitionMatrix(3).txt = Text file containing the data used for calculating the transition matrices

b) Output_RatingTransitionMatrix(1).xlsx = Excel file that illustrates the final results provided by the specific R package 


I would be so grateful if you are able to send me a code developed in SAS in order to achieve the same/or similar results.
Thanks in advance.


> I would be so grateful if you are able to send me a code developed in SAS in order to achieve the same/or similar results.


I suspect you will need to do some preliminary work on this problem before we will be able to offer help. Typically, the OP will post a program and ask questions about parts of the code that are confusing or not working. We can then offer advice, discuss strategies, and propose ways to modify your code.


Do you know how to write a transition matrix? If not, start with


There are also papers about Markov transition matrices in SAS by searching the conference proceedings at
      markov transition matrix iml



Calcite | Level 5
Thanks Rick,
I was assuming that SAS has already had developed something like that in a specific Proc statement, given that other languages like R, Python, Matlab and etc have already implemented it easily. Said that, I think I’m gonna use what other languages have to offer, instead of trying to develop something from scratch in SAS.

This forum is for writing SAS/IML programs, so that is why I assumed you wanted to write an IML program. SAS has a  lot of functionality for econometric, forecasting, and credit risk. I don't know all the offerings., but others who have backgrounds in forecasting might be able to point you to other SAS products.


I will move this thread to the Forecasting and Econometrics community. Hopefully someone there will know how to perform this functionality in SAS.

Calcite | Level 5
Hello Ricky
Actually, I have tried to write a code using the SAS/IML statement, however, I’m not envisioning to spend a huge time trying to do that. What makes me disappointed is that the attention provided in R and Python forums is much better if compared to what I received here, given that these folks provided me some very useful examples from scratch, step-by-step, in order to achieve what I’m looking for, however, using R and Python and not SAS.

Hello @raphaelchaves ,


In general you get very good (high quality) code examples in this communities site (and certainly from Rick), but you have to give a bit of a lead. Especially when there are so much methods and approaches to achieve "the same". 

It is also quite a complex thing (although that is relative of course). Correcting code is then easier than coughing it up from scratch (I do not know if the latter sentence is proper English 🙄).

I'm not in finance consulting anymore (I was a lot before 2010 for Basel II) but I'm as good as sure the SAS solutions for Risk Management and Risk and Finance Analytics have built-in credit migration transition matrices. Maybe you can contact your local SAS office to find out.


Also have a look at the SSM procedure (for State Space Models ) in SAS/ETS. I think it should be able to do what you're looking for.


Kind regards,




Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 3 in conversation