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

I have 4 treatment groups to be displayed in the graph. I need different linestyles (solid, dashed, etc ..) for each treatment group. 

With the below code which I have written, I'm getting same linestyle for all 4.

 

How to use the linestyle option in sgplot ? Please enlighten me. I am a beginner. Thanks


proc sgplot data = final noautolegend;
xaxis label = 'Week';
yaxis label = 'Blood Pressure (mmHg)';

series x = visitname y = mean / group = trtp lineattrs = (pattern = 1) markers;
keylegend/ title = 'Treatment ';
scatter x = visitname y = mean / group = trtp yerrorlower = lower
yerrorupper = upper ;
run;

 

 

Thankyou

1 ACCEPTED SOLUTION

Accepted Solutions
djrisks
Barite | Level 11

Hello, I agree with Sanjay's comments. Just wanted to also mention that the reason why you are getting the same linestyle for each treatment is because you are using this option "lineattrs = (pattern = 1)". If you remove that code from the options (and assuming you are creating listing or rtf output) than you will automatically get different linestyles for each treatment.

 

If you wanted to also specify the exact color and linestyle that each treatment should have than you can do this with the discrete attributes map statements. http://blogs.sas.com/content/graphicallyspeaking/2013/04/06/attributes-map-2/

 

Thanks.

View solution in original post

4 REPLIES 4
Jay54
Meteorite | Level 14

Starting with SAS 9.3, the default style for HTML destination is HTMLBLUE.  This uses a "Color" priority algorithm to cycle through the attributes such as color, line pattern and symbol.  If you have SAS 9.3, use some other style, like LISTING.

 

If you have SAS 9.4 and want to keep the HTMLBlue style , but change the attribute assignment, set ATTRPRIORITY=NONE on the ODS Graphics statement.  This will cycle through color and line patterns for each group.

 

See this article for more information on ATTRPRIORITY:  http://blogs.sas.com/content/graphicallyspeaking/2015/06/28/attributes-priority-for-the-inquiring-mi...

 

bobbyc
Fluorite | Level 6
Thanks Sanjay. This helped me to learn something new.
djrisks
Barite | Level 11

Hello, I agree with Sanjay's comments. Just wanted to also mention that the reason why you are getting the same linestyle for each treatment is because you are using this option "lineattrs = (pattern = 1)". If you remove that code from the options (and assuming you are creating listing or rtf output) than you will automatically get different linestyles for each treatment.

 

If you wanted to also specify the exact color and linestyle that each treatment should have than you can do this with the discrete attributes map statements. http://blogs.sas.com/content/graphicallyspeaking/2013/04/06/attributes-map-2/

 

Thanks.

Jay54
Meteorite | Level 14

Good catch.  I missed that part that LINEATTRS is specified.  It is also preferable to NOT use patterns by numbers as you may not get good results.  Please only use the named patterns defined in the software documentation.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 3779 views
  • 6 likes
  • 3 in conversation