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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

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