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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.