Turn on suggestions

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

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- out of sample regression testing with sas studio

Options

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 03-11-2020 11:48 AM
(832 views)

I am very very very new to SAS and to be fair I haven't learnt from the start, I was just thrown into producing regressions, so I am not very acquainted with the language.

I have two excel datasets, one for training and one for testing the regression.

What I want to know is how to use the fitted logistic regression to "predict" the classes for the test set.

I am not running these regressions by writing the code myself, I am simply adjusting the settings. Nonetheless, here's the code that I get

from training the logistic regression:

```
ods noproctitle;
ods graphics / imagemap=on;
proc logistic data=WORK.TRAIN2 plots=(roc);
class checking_1 checking_23 savings_1 savings_23 amount_to1400
amount_1400to1600 amount_1600to2200 amount_2200to3800 purpose_189 purpose_26
purpose_05 / param=glm;
model Good(event='1')=checking_1 checking_23 savings_1 savings_23
amount_to1400 amount_1400to1600 amount_1600to2200 amount_2200to3800
purpose_189 purpose_26 purpose_05 / link=logit technique=fisher;
run;
```

My test dataset is called TEST2. How can I achieve this?

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Here's a blog post that illustrates 4 different ways of doing this. Don't try PLM if this is all new to you.

https://blogs.sas.com/content/iml/2014/02/19/scoring-a-regression-model-in-sas.html

There's also a full example in the documentation for PROC LOGISTIC (see the little link under the heading to the full code so you can run and test the example).

@catkat96 wrote:

I am very very very new to SAS and to be fair I haven't learnt from the start, I was just thrown into producing regressions, so I am not very acquainted with the language.

I have two excel datasets, one for training and one for testing the regression.

What I want to know is how to use the fitted logistic regression to "predict" the classes for the test set.

I am not running these regressions by writing the code myself, I am simply adjusting the settings. Nonetheless, here's the code that I get

from training the logistic regression:

`ods noproctitle; ods graphics / imagemap=on; proc logistic data=WORK.TRAIN2 plots=(roc); class checking_1 checking_23 savings_1 savings_23 amount_to1400 amount_1400to1600 amount_1600to2200 amount_2200to3800 purpose_189 purpose_26 purpose_05 / param=glm; model Good(event='1')=checking_1 checking_23 savings_1 savings_23 amount_to1400 amount_1400to1600 amount_1600to2200 amount_2200to3800 purpose_189 purpose_26 purpose_05 / link=logit technique=fisher; run;`

My test dataset is called TEST2. How can I achieve this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Thank you so much! The second link was really useful and now I can do it for logistic regression.

I also need to do the same for linear regression (with the same datasets too), but I find that the initial code is a bit different, so I'm not sure the outmodel/inmodel thing works.

Do you happen to have a link to the documentation that explains this too?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

The PROC SCORE documentation has one for PROC REG.

https://documentation.sas.com/?docsetId=statug&docsetVersion=14.3&docsetTarget=statug_score_examples...

https://documentation.sas.com/?docsetId=statug&docsetVersion=14.3&docsetTarget=statug_score_examples...

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

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.

Ready to level-up your skills? Choose your own adventure.