Data visualization with SAS programming

Can I put multiple regression lines on a plot ?

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,636
Accepted Solution

Can I put multiple regression lines on a plot ?

Dear All,

Can I put three regression lines(age vs weight) on the same plot(based on dataset class)?

One line is for a regression line with gender=0, another with gender=1, another with gender=2?

data class1;

  set sashelp.class;

  gender=0;

data class2;

  set sashelp.class;

   if sex='M' then gender=1;

     else gender=2;

data class;

   set class1 class2;

proc sort data=class;

  by gender age;

run;

Thank you very much!


Accepted Solutions
Solution
‎10-29-2012 03:35 PM
Respected Advisor
Posts: 4,606

Re: Can I put multiple regression lines on a plot: ?

Sorry, I should have read more carefully...

proc sgplot data=class;

reg y=weight x=age / group=gender clm clmtransparency=0.4 lineattrs=(pattern=solid);

run;

PG

PG

View solution in original post


All Replies
Frequent Contributor
Frequent Contributor
Posts: 94

Re: Can I put multiple regression lines on a plot: ?

symbol1 value=none i=r ci=black;
symbol2 value=none i=r ci=blue;
symbol3 value=none i=r ci=green;

PROC GPLOT DATA=class;
PLOT Age *Weight=Gender/
;

RUN;  QUIT;

Super Contributor
Posts: 1,636

Re: Can I put multiple regression lines on a plot: ?

Thank you VD!

I found the "regeqn" option.

Respected Advisor
Posts: 4,606

Re: Can I put multiple regression lines on a plot: ?

Or :

proc sgplot data=class;

series y=weight x=age / group=gender;

run;

PG

PG
Super Contributor
Posts: 1,636

Re: Can I put multiple regression lines on a plot: ?

Thank you PG!  I am not familiar with SAS graphs.  I need the regression line.

I found an example on line:

title1

  ’Linear Regression of Height and Weight’;

title2 ’(with 95% Confidence Limits)’;

symbol ci=red cv=blue co=gray value=dot

       interpol=rlclm95 ;

proc gplot data=sashelp.class;

   plot height*weight / regeqn;

run; quit;

Solution
‎10-29-2012 03:35 PM
Respected Advisor
Posts: 4,606

Re: Can I put multiple regression lines on a plot: ?

Sorry, I should have read more carefully...

proc sgplot data=class;

reg y=weight x=age / group=gender clm clmtransparency=0.4 lineattrs=(pattern=solid);

run;

PG

PG
Super Contributor
Posts: 1,636

Re: Can I put multiple regression lines on a plot: ?

Thank you PG!!Smiley Happy  Linlin

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 5137 views
  • 3 likes
  • 3 in conversation