I would like to get the legend label, with "Treatement" above the 2 groups "Placebo 30 mg BID".
Attached is the 2 figures. I want the beginning one with 'Treatment' on top.
The program I have now, below, produces the latter one with 'Treatment' on the side.
proc sgplot data=all pad=(bottom=25% left=20%) uniform=all ;
where trtp~='';
*format typen type. trtan trt.;
vbar PARAM / response=percent group=trtpn groupdisplay=cluster name='a' /*BARWIDTH=0.8*/;
keylegend 'a' / location=outside position=bottom TITLE='Treatment' ;
xaxis display=(nolabel noticks);
yaxis display=all offsetmin=0.02 offsetmax=0.1 thresholdmin=1 thresholdmax=1
label="Response Rate (%)" values=(0 to 52 by 5) ;*valueattrs=(family=&font. size=8pt weight=normal);
format trtpn trt.;
run;
Thanks,
Daniel
From the documenation
TITLE=“text-string”
specifies a title for the legend. The title is placed to the left of the legend body, except in the following cases:
the legend contains two or more rows of items the legend title length exceeds the space that is available on the left side of the legendIn those cases, the title is placed above the legend body.
So either have 2 or more rows by setting across=1, make the title text much longer or make the formatted text values of group variable longer to take up more space. Since most of the SAS procs will ignore trailing blanks you might be able to get that by providing leading blank characters before the actual text. If this works alignment is likely to be very iffy. The amount of space for the title this way is very dependent on the amount of space the value entries occupy. So if your formatted values for the group variables are longer you might also get what you want. I suspect physically wider graphs have more allowable space to use so that might be something else to consider.
Or you may want to provide your legend with no title and use an Annotate data set to place text in the right place.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.