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

Hi--

I've reached my limit of tinkering to figure this out.

 

Is there a way to overlay multiple graph types in a single graph?

 

I have a data set with columns X Y1 Y2 Y3 and Y4.

 

I want to plot Y1 using a scatter plot (points color coded by group for a little extra level of complication)

I want Y2 to be plotted with just a simple line

I want Y3 and Y4 to be plotted with a different line type

basically a combination of these two styles basically.  I'd like the top one, but with the colors by group as is so easily produced in SGPlot

 

Thank you.

iiibbb_2-1591031373088.png

 

 

iiibbb_1-1591031330329.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
iiibbb
Quartz | Level 8

Ahh.

 

I feel certain I had tried this already... but it's easy.

 

proc sgplot data=a;
styleattrs datasymbols=(circlefilled);
scatter y=Y1 x=X1 / group=groupname;
series y=Y2 x=X1;
series y=Y3 x=X1 / lineattrs = (pattern=shortdash);
series y=Y4 x=X1 / lineattrs = (pattern=shortdash);
run;
quit;

View solution in original post

3 REPLIES 3
PaigeMiller
Diamond | Level 26

Yes, in PROC SGPLOT you use the REG command with the option NOMARKERS to get the confidence limits and regression line. Then you add a SCATTER statement to get the data points colored as you wish.

--
Paige Miller
iiibbb
Quartz | Level 8

I saw that feature.  Unfortunately, I'm not using an OLS regression in this case, so the regression methods won't match the models I'm actually building.

I think the solution may lie in the series statements, I'm still tinkering.

iiibbb
Quartz | Level 8

Ahh.

 

I feel certain I had tried this already... but it's easy.

 

proc sgplot data=a;
styleattrs datasymbols=(circlefilled);
scatter y=Y1 x=X1 / group=groupname;
series y=Y2 x=X1;
series y=Y3 x=X1 / lineattrs = (pattern=shortdash);
series y=Y4 x=X1 / lineattrs = (pattern=shortdash);
run;
quit;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2333 views
  • 0 likes
  • 2 in conversation