Desktop productivity for business analysts and programmers

How to build Markov chain model in SAS enterprise guide

Reply
New Contributor
Posts: 4

How to build Markov chain model in SAS enterprise guide

Hello,

 

I only have SAS enterprise guide installed (i.e. no SAS PC), and I'm not able to run PROC IML , and my purpose is to build a Markov Chain Model (the datasets are saved on SAS servers, some internet server of my company I believe). 

 

So could anyone tell me how to build such model with all I have now?

 

Thanks very much!

 

 

 

PROC Star
Posts: 1,265

Re: How to build Markov chain model in SAS enterprise guide

(Don't you hate it) Let me answer a question with a question: why do you mention not having SAS PC?

 

Is your question a theoretical one of how to build the model, or do you know how to do it with SAS PC, and are wondering how to do it using EG?

 

Are you aware that you can submit SAS code in a code window in EG, just like you can on SAS PC?

 

Also, if the server used by your EG installation is licensed for IML, you can also submit IML jobs in EG.

 

Tom

New Contributor
Posts: 4

Re: How to build Markov chain model in SAS enterprise guide

Thank you so much for your reply Tom! 

 

Let me answer your questions, hope my answers would be clear to you:

 

why do you mention not having SAS PC? -- because I did some search and found that PROC IML can be run in SAS PC

 

Is your question a theoretical one of how to build the model, or do you know how to do it with SAS PC, and are wondering how to do it using EG? -- my main question is to build the model using EG

 

Are you aware that you can submit SAS code in a code window in EG, just like you can on SAS PC? -- yes

 

Also, if the server used by your EG installation is licensed for IML, you can also submit IML jobs in EG. -- unfortunately, I'm not able to run PROC IML, so I guess IML is not licensed on my EG version?

 

so based on these conditions, do you have any suggestion? Thanks again!

PROC Star
Posts: 1,265

Re: How to build Markov chain model in SAS enterprise guide

Perfect! Thanks for the nice clear answers.

 

First, take a look at the reply from @mkeintz, and if he solves your problems, you're away to the races.

 

Second, double check whether you can successfully run IML from EG. There is an issue between these two, in that every time you submit code EG puts a "quit;" statement in automatically, so you can't run IML in interactive mode. If you're licensed for IML, though, you can still run it using "proc iml". For instance, the following (from an introductory paper by Rick Wicklin) runs fine in a code window in EG on my machine:

 

proc iml; /* In SAS/IML Studio, PROC IML stmt is optional */
/* convert temperatures from Celsius to Fahrenheit scale */
Celsius = {-40, 0, 20, 37, 100}; /* vector of temperatures */
Fahrenheit = 9/5 * Celsius + 32; /* convert to Fahrenheit */
print Celsius Fahrenheit; /* send to ODS destination */
quit;

 

 

And finally, if you really can't run IML, I suggest you repost in the Analytics/SAS Statistical Procedures community, with a title like "How to build Markov chain model without using IML". That way, the people with good statistical chops will see it. The Enterprise Guide community tends to get posts about actually using EG, not about how to use the underlying SAS code to get challenging statistical results.

 

Good luck!

   Tom

New Contributor
Posts: 4

Re: How to build Markov chain model in SAS enterprise guide

Thank you Tom! I tried the code you provided, and there is no IML licensed indeed, but I can either try mkeintz' method or trying to asking EG community another question. I really appreciated your and @mkeintz ' assistance!

Trusted Advisor
Posts: 1,288

Re: How to build Markov chain model in SAS enterprise guide

You can do matrix multiplication via PROC SCORE.  Assume two datasets, right and left:

 

data left;
  _type_='SCORE';
  input _NAME_ $7. x1 x2;
datalines;
newvar1 10 20
newvar2 25 40
run;

data right;
  input x1 x2;
datalines;
1 2
2 4
run;

proc score data=right score=left   out=product;
run;

data _null_; set product; put (_all_) (=);run;

 

Proc score is intended to generate factor scores from original data, using the SCORE coefficients generated by proc factor.

 

Somewhere there is probably a well-developed paper on using PROC SCORE for markov chains, .. but I can't readily find it.

New Contributor
Posts: 4

Re: How to build Markov chain model in SAS enterprise guide

Thank you mkeintz! This is very helpful!

Super User
Posts: 10,618

Re: How to build Markov chain model in SAS enterprise guide

Calling @Rick_SAS

SAS Super FREQ
Posts: 4,118

Re: How to build Markov chain model in SAS enterprise guide

Are you talking about Markov transition models in which the probabilities of transitioning to State K depends on the current state?

See the articles

Yes, both of these article use SAS/IML. Why? Because Markov transition models are inherently about matrix operations (multiplication, inversion, eigenvectors,...) 

 

I realize that not every site licenses SAS/IML, but trying to build a Markov model without high-level matrix operations is going to cost quite a bit of money in terms of your time/salary/sanity for development, testing, and maintenance. If your company thinks these models are important, you might do a cost/benefit analysis to see whether it makes economic sense to license SAS/IML.  If you are going to build something, sometimes it is more efficient to purchase the correct power tools. 

Ask a Question
Discussion stats
  • 8 replies
  • 797 views
  • 0 likes
  • 5 in conversation