BookmarkSubscribeRSS Feed
Nives_ES
Calcite | Level 5


I am learning how to do spaghetti plots using Proc SGPlot.

I am having trouble creating a profile plot for each individual subject ID and then to use different colors for males and females.

This is what I have so far:

sgplot data=DentalL;
series y=Response x=Time / Break group=ID;

xaxis values=(6 to 16 by 2) label='Age in years';

yaxis values=(0 to 35 by 5) label='Dental Growth in mm';

title 'Individual Profiles';
run;
quit;

Can anyone help me use different line colors for different genders?

2 REPLIES 2
data_null__
Jade | Level 19

I think this tread covers it pretty well.  I have use dummy obs and the break option and then specify GROUP=gender etc.  There are newer options too if you have a more current version of SAS, see entire thread.

https://communities.sas.com/thread/71469

Jay54
Meteorite | Level 14

With SAS 9.40M2, this is easy using the new ColorLC and ColorLP options:  http://blogs.sas.com/content/graphicallyspeaking/?s=spaghetti.

If you have earlier versions of SAS, the easiest way would be to use the corresponding options available in GTL called LINECOLORGROUP and LINEPATTERNGROUP.  They may not be documented, but have been in the code since SAS 9.2. and have been documented since SAS 9.4.   Just output the GTL code from the SGPLOT using the TMPLOUT option, and then add these options to the SERIESPLOT statement.

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
  • 2 replies
  • 4145 views
  • 0 likes
  • 3 in conversation