BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sfo
Quartz | Level 8 sfo
Quartz | Level 8

Hi,

 

I have SAS 9.2 and I need to display the linear regression line and R-Squared or the p-value on the plot. I have three groups and my plot looks something like attached.

 

Is it possible to display the regression line superimposed on the colored dots? I am trying the following for scatter plot and regression analysis:

 

proc gplot data = plot_data anno= anno ;
plot yaxis*xaxis=cohort_no /vaxis=axis1 haxis=axis nolegend noframe;

run;

proc reg data = plot_data anno= anno1 ;
model yaxis = xaxis;
plot yaxis*xaxis ;
run;

 

Thanks a lot

 


Plot.png
1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

Most statisticians do not use the old PLOTS statement anymore. Instead, most use ODS statistical graphics, which are produced automatically by most SAS/STAT procedures. See the following two examples:

 

ods graphics on;
proc reg data =sashelp.class plots=FitPlot(stats=DEFAULT);
model weight = height;
quit;

proc glm data =sashelp.class plots=FitPlot;
class sex;
model weight = height | sex;
quit;

For an overview, see Rodriguez (2009) "Getting Started with ODS Statistical Graphics in SAS 9.2."

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

Most statisticians do not use the old PLOTS statement anymore. Instead, most use ODS statistical graphics, which are produced automatically by most SAS/STAT procedures. See the following two examples:

 

ods graphics on;
proc reg data =sashelp.class plots=FitPlot(stats=DEFAULT);
model weight = height;
quit;

proc glm data =sashelp.class plots=FitPlot;
class sex;
model weight = height | sex;
quit;

For an overview, see Rodriguez (2009) "Getting Started with ODS Statistical Graphics in SAS 9.2."

ballardw
Super User

If you want to continue with GPLOT your solution would involve setting a Symbol statement to show the desired regression for each level of your cohort_no.

Something like

 

symbol1 i=RL color=red;

 

The i or Interpol option R is for regression options are availble for showing confidence limits of individual responses or the mean and the interval for the confidence limits as well.

sfo
Quartz | Level 8 sfo
Quartz | Level 8

Thanks for the reply.

 

I amting two get different regression line plots, when I use PROC REG and when I use proc gplot see below, could you help me why?

 

Code:

For R squared value using proc reg

proc reg data = plot_data outest=reg_val outsscp=sscp1 rsquare;
model yaxis = xaxis ;
plot yaxis*xaxis;
run;
quit;

 

for scatter plot using gplot

symbol1 i=none v=dot w=2 l=3 h=4 color=blue;
symbol2 i=none v=C w=2 l=4 h=2.5 f=marker color=red;
symbol3 i=none v=U w=2 l=4 h=2.5 f=marker color=green;
symbol4 i=none w=2 l=3 h=3 i=rl color=black;

 

proc gplot data = plot_data anno= anno1 ;
plot yaxis*xaxis=cohort_no /vaxis=axis1 haxis=axis2 nolegend noframe;
plot2 yaxis*xaxis/ noaxis;
run;
quit;

 

 


Proc gplot.pngProc Reg.png

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 3 replies
  • 7059 views
  • 1 like
  • 3 in conversation