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
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.
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...
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.
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.
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.
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.