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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 522 views
  • 1 like
  • 3 in conversation