BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Linlin
Lapis Lazuli | Level 10

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!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

6 REPLIES 6
VD
Calcite | Level 5 VD
Calcite | Level 5

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;

Linlin
Lapis Lazuli | Level 10

Thank you VD!

I found the "regeqn" option.

PGStats
Opal | Level 21

Or :

proc sgplot data=class;

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

run;

PG

PG
Linlin
Lapis Lazuli | Level 10

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;

PGStats
Opal | Level 21

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
Linlin
Lapis Lazuli | Level 10

Thank you PG!!Smiley Happy  Linlin

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 10940 views
  • 3 likes
  • 3 in conversation