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

I have a dataset that contains the state details for 50 customers from time T1 to T20. The rows have customer ID followed by the sequence of states they were in for the past 20 time periods. There are only 4 states A, B, C, D. the data looks like this:
 
CUS-ID  T1 T2 ... T20
C1         D C ...  B
C2         C D ... A
...
C50      A C ... B
 
Using Markov chains I want to predict the state at time T21 and the associated probability of being in that predicted state. Is there a way in SAS where I can use a PROC or do I have to code from scratch? I also need help writing the code from scratch if there are no special PROCs.
I also do not have any initial transition probabilities. Is there a good rule that I can base my initial transition probabilities on?
Any help on documentation specific to similar problems will be much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

I think you should transform your data like:

 

ID PREV CURRENT

C1 D    C

C1 C   A

 

After that ,using proc freq to get transform probability .

And PROC TRANSPOSE to get transform matrix .

And put this matrix into SAS/IML and do some matrix multiply operator.

View solution in original post

5 REPLIES 5
Ksharp
Super User

I think you should transform your data like:

 

ID PREV CURRENT

C1 D    C

C1 C   A

 

After that ,using proc freq to get transform probability .

And PROC TRANSPOSE to get transform matrix .

And put this matrix into SAS/IML and do some matrix multiply operator.

SC_1991
Fluorite | Level 6

Are you implying that I have only 2 time periods ( prev and current) and then calculate the transition probabilities or did you mean arrange the states from left to right left being the earliest?

Ksharp
Super User

"mean arrange the states from left to right left being the earliest"

vrushankshah
Fluorite | Level 6
Hello were you able to get the answer ? Because I have similar question and I am also looking for some programme to do it

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 2554 views
  • 1 like
  • 3 in conversation