BookmarkSubscribeRSS Feed
shahd
Quartz | Level 8

in variable selection method to choose the best subset of models. How can I create a plot for cp with p and r adj with p

 

here is my code for all possible regressions 

 

 

proc reg data=salary;

  model y=x1 x2 x3 x4 x5 x6 x7 x8 x9 x10/

      selection=rsquare cp mse adjrsq aic bic best=10 b;

8 REPLIES 8
Reeza
Super User
Capture output into a table, using ODS most likely and then graph it using SGPLOT.
shahd
Quartz | Level 8
could you please help me with the code for this part
shahd
Quartz | Level 8
goptions ctitle=black htitle=3.5pct ftitle=swiss
ctext =magenta htext =3.0pct ftext =swiss
cback =ligr border;
symbol1 v=circle c=red h=1 w=2;
title 'Cp Plot with Reference Lines';
symbol1 c=green;
proc reg data=salary;
model salary=x1 x2 x3 x4 x5 x6 x7 x9 x10
/ selection=rsquare noprint;
plot cp.*np.
/ chocking=red cmallows=blue
vaxis=0 to 15 by 5 cframe=ligr;
run;

I wrote this code and it give me error
Reeza
Super User

There are two concepts you need to learn. 

1. How to capture data from SAS procedures into data sets:

https://blogs.sas.com/content/iml/2017/01/09/ods-output-any-statistic.html

 

2. How to graph:

http://people.uncw.edu/blumj/stt592/ppt/Introduction%20to%20the%20SGPLOT%20Procedure.pdf

 

I've posted answers to your questions that was fully coded and illustrated this, and you've posted several questions that are pretty much all examples of this procedure. It's worth spending the day or so to learn these two topics well enough. 

 

Your code currently is a mix of PROC REG and GPLOT, and by that I mean you've mixed up procedures entirely. I do not see a GPLOT statement at all in your code though. I do not use GPLOT so cannot comment on that portion. The general recommendation these days is to not use GPLOT, it's to use SGPLOT because it's easier, graphics are higher quality and there are more graph types and options to customize it. 

 


@shahd wrote:
goptions ctitle=black htitle=3.5pct ftitle=swiss
ctext =magenta htext =3.0pct ftext =swiss
cback =ligr border;
symbol1 v=circle c=red h=1 w=2;
title 'Cp Plot with Reference Lines';
symbol1 c=green;
proc reg data=salary;
model salary=x1 x2 x3 x4 x5 x6 x7 x9 x10
/ selection=rsquare noprint;
plot cp.*np.
/ chocking=red cmallows=blue
vaxis=0 to 15 by 5 cframe=ligr;
run;

I wrote this code and it give me error

 

 

shahd
Quartz | Level 8

I couldnot open the second link of how to graph

Reeza
Super User

This isn't mine, it's from a google search, but appears relatively good.

shahd
Quartz | Level 8

I couldnot figure it out 😞

Reeza
Super User

Which part? What did you try?

 

You need to break these down into steps and then try and solve each step individually. If you try and do it all at once you will not get anywhere. 

 

The steps are:

 

1. Get data from PROC REG into a data set

2. Graph with SGPLOT - customize after base plot is obtained. 

 

FYI - I am more than happy to help but I'm not going to write the code for you - my personal choice. Someone else may, if that's what you want, you can wait and see if someone else responds. 

 


@shahd wrote:

I couldnot figure it out 😞


 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1758 views
  • 0 likes
  • 2 in conversation