Hi all. I have data:
trtpn visit median q1 q3
1 2 0 0 0
2 2 0 0 0
3 2 0 0 0
1 3 2 1 4
2 3 1 -2 3
3 3 3 1 4
1 4 -2 -3 2
2 4 2 -1 3
3 4 2 -1 3
and i am using code below to plot median and interquartile:
proc sgplot data=mydata noautolegend;
styleattrs datasymbols=(circlefilled asterisk tranglefilled)
Datalinepatterns=(solid solid solid)
DATACONTRASTCOLORS=(blue green magenta);
series x=visitn y=median / group=trtpn groupdisplay=cluster clusterwidth=0.5;
scatter x=visitn y=median/yerrorlower=q1 yerrorupper=q3 group=trtpn groupdisplay=cluster clusterwidth=0.5 errorbarattrs=(thickness=1) markerattrs=(size=7) name='s';
xaxis values=(2,3,4) fitpolicy=rotate grid ;
yaxis grid values=(-80 to 20 by 20);
keylegend 's'/title="Treatment Group:" down=1 location=outside position=bottom noborder;
However, the color for plot is not as indicated in the DATACONTRASTCOLORS=(blue green magenta), but it plots everything in black. Does anyone knows how to change color?
Thank you!
data mydata;
input trtpn visitn median q1 q3;
cards;
1 2 0 0 0
2 2 0 0 0
3 2 0 0 0
1 3 2 1 4
2 3 1 -2 3
3 3 3 1 4
1 4 -2 -3 2
2 4 2 -1 3
3 4 2 -1 3
;
ods graphics/attrpriority=none;
proc sgplot data=mydata noautolegend;
styleattrs datasymbols=(circlefilled X trianglefilled)
DATACONTRASTCOLORS=(blue green magenta)
DATACOLORS=(blue green magenta);
series x=visitn y=median / group=trtpn groupdisplay=cluster clusterwidth=0.5 lineattrs=(pattern=solid);
scatter x=visitn y=median/yerrorlower=q1 yerrorupper=q3 group=trtpn groupdisplay=cluster clusterwidth=0.5 errorbarattrs=(thickness=1) markerattrs=(size=7) name='s';
xaxis values=(2,3,4) fitpolicy=rotate grid ;
yaxis grid values=(-80 to 20 by 20);
keylegend 's'/title="Treatment Group:" down=1 location=outside position=bottom noborder;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.