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

Hi,

I used sgplot to get hbox. I want to make one hbox (eg. the top bar) is different to show that is a specific case. Either to put a star aside the box or make the color different. Both I did not find how to make it. Hope some one can help.

Thanks,

Andrea

 

The graph looks like:

 

SGPlot18.png

 

My code:

 

proc sgplot data=Caterpillar_graph noautolegend noborder;
hbox VAS_preop / category=surgeon_id nocaps extreme fillattrs=(color=CXE7AF19) WHISKERATTRS=(color=black) MEDIANATTRS=(color=CX2D3884 thickness=8) nomean;
refline 75 /axis=x lineattrs=(color=CX2D3884) LEGENDLABEL= "National Median" name='line';
refline '*'/axis=x;
yaxis label = "Individual Surgeon" display=(novalues noticks) labelattrs=(size=10pt FAMILY="Segoe UI Symbol") DISCRETEORDER=DATA;
xaxis label = "VAS" labelattrs=(size=10pt FAMILY="Segoe UI Symbol")  values = (0 to 100 by 10);
keylegend "line" ;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
JeffMeyers
Barite | Level 11

I would create a separate variable that you can use in the GROUP option.  Something like the following:

data caterpillar_graph2;
   set caterpillar_graph;
   if surgeon_id=certain_value then highlight=1;
   else highlight=2;
run;

proc sgplot data=Caterpillar_graph2 noautolegend noborder;
styleattrs datacolors=(green CXE7AF19) datacontrastcolors=(black black);
hbox VAS_preop / category=surgeon_id nocaps extreme WHISKERATTRS=(color=black) MEDIANATTRS=(color=CX2D3884 thickness=8) nomean
GROUP=highlight;
refline 75 /axis=x lineattrs=(color=CX2D3884) LEGENDLABEL= "National Median" name='line';
refline '*'/axis=x;
yaxis label = "Individual Surgeon" display=(novalues noticks) labelattrs=(size=10pt FAMILY="Segoe UI Symbol") DISCRETEORDER=DATA;
xaxis label = "VAS" labelattrs=(size=10pt FAMILY="Segoe UI Symbol")  values = (0 to 100 by 10);
keylegend "line" ;
run;

I don't have your data so I can't give the exact code.  I removed the FILLATTRS since you now have a GROUP variable and would want to control different fill colors with the STYLEATTRS statement instead.  Depending on your OS and platform you're running on you might have to change some other ATTRS options as well.

 

 

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

Using a small annotate data set is your best option.

Andrea_Peng
Obsidian | Level 7
Thanks, how to set up?
ChrisNZ
Tourmaline | Level 20
Many resources about using annotate. Try and report here if you have trouble.
JeffMeyers
Barite | Level 11

I would create a separate variable that you can use in the GROUP option.  Something like the following:

data caterpillar_graph2;
   set caterpillar_graph;
   if surgeon_id=certain_value then highlight=1;
   else highlight=2;
run;

proc sgplot data=Caterpillar_graph2 noautolegend noborder;
styleattrs datacolors=(green CXE7AF19) datacontrastcolors=(black black);
hbox VAS_preop / category=surgeon_id nocaps extreme WHISKERATTRS=(color=black) MEDIANATTRS=(color=CX2D3884 thickness=8) nomean
GROUP=highlight;
refline 75 /axis=x lineattrs=(color=CX2D3884) LEGENDLABEL= "National Median" name='line';
refline '*'/axis=x;
yaxis label = "Individual Surgeon" display=(novalues noticks) labelattrs=(size=10pt FAMILY="Segoe UI Symbol") DISCRETEORDER=DATA;
xaxis label = "VAS" labelattrs=(size=10pt FAMILY="Segoe UI Symbol")  values = (0 to 100 by 10);
keylegend "line" ;
run;

I don't have your data so I can't give the exact code.  I removed the FILLATTRS since you now have a GROUP variable and would want to control different fill colors with the STYLEATTRS statement instead.  Depending on your OS and platform you're running on you might have to change some other ATTRS options as well.

 

 

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
  • 761 views
  • 1 like
  • 3 in conversation