BookmarkSubscribeRSS Feed
catkat96
Obsidian | Level 7

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
Reeza
Super User

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).

https://documentation.sas.com/?docsetId=statug&docsetVersion=15.1&docsetTarget=statug_logistic_examp...

 


@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? 


 

catkat96
Obsidian | Level 7

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?

SAS INNOVATE 2024

Innovate_SAS_Blue.png

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!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 340 views
  • 0 likes
  • 2 in conversation