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:
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;
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.
Using a small annotate data set is your best option.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.