ods html style = journal2;
proc sgplot data =WORK.PLAY pctlevel=group;
hbar Q68 / GROUP=Q3 groupdisplay=stack grouporder=descending
stat=percent barwidth=0.80 seglabel seglabelattrs=(family="Arial" size=12pt weight=bold) seglabelfitpolicy=noclip datalabel=; keylegend/ noborder title="" location=outside position=right across=1 valueattrs=(size=13pt) sortorder=descending;
yaxis valueattrs=(Family="Arial" size= 13pt) label = "Sex" Labelattrs=(family="Arial" size= 13pt);
xaxis valueattrs=(Family="Arial" size= 13pt) label = "Percentage" Labelattrs=(Family= "Arial" size= 13pt);
run;
Hello there,
I am stuck and need to have a readable graph. I am creating a bivariate horizontal bargraph (of Q3No. of ER visits vs. Q68sex) using PROC SGPLOT with Journal2 style. Is there any way I can move the segment labels from inside the bars to outside just so that they are legible? Apologies, I am unable to show the data.
The output for the code below is shown in attachment "figure ER visits vs sex".
I am looking to produce the graph with labels as seen in the attachment "What I want my graph to look like ER vs sex".
I appreciate the help.
The basic approach I would take would be to
1) summarize the data creating the percentage values you need
2) add the TEXT of the values as a new variable with compatible horizontal and vertical axis values
3) add a TEXT plot
4) modify the hbar to remove segment labels entirely and make sure there is sufficient space between the bars for the text and to have a TEXT plot an HBARPARM would be needed for compatibility.
If your current variable for Sex is character you may need to change to a numeric with appropriate format so the X Y coordinates can make sense.
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: