turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- BI
- /
- Enterprise Guide
- /
- How to build Markov chain model in SAS enterprise ...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-28-2017 02:56 PM

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!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bookage

09-28-2017 04:34 PM

(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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to TomKari

09-28-2017 05:06 PM

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!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bookage

09-28-2017 05:22 PM

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

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to TomKari

09-29-2017 10:05 AM

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!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bookage

09-28-2017 04:40 PM

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.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to mkeintz

09-29-2017 10:02 AM

Thank you mkeintz! This is very helpful!

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to bookage

09-29-2017 10:54 AM

Calling @Rick_SAS

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Ksharp

09-29-2017 11:09 AM

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.