BookmarkSubscribeRSS Feed
VioletaB
Calcite | Level 5

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!

1 REPLY 1
Ksharp
Super User
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;

Ksharp_0-1678797482784.png

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1 reply
  • 582 views
  • 0 likes
  • 2 in conversation