Quartz | Level 8

## variable selection method

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

## Re: variable selection method

Capture output into a table, using ODS most likely and then graph it using SGPLOT.
Quartz | Level 8

Quartz | Level 8

## Re: variable selection method

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

## Re: variable selection method

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

Quartz | Level 8

## Re: variable selection method

I couldnot open the second link of how to graph

Super User

## Re: variable selection method

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

Quartz | Level 8

## Re: variable selection method

I couldnot figure it out 😞

Super User

## Re: variable selection method

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 😞

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