Hello everyone,
I am trying to add an overall title for the by two yaxistables. I have attached a version of the sgplot graph I am working on. The output destination is the standard ODS HTML. I would like to put a tittle above each yaxistable shown by TITLE1 and TITLE2. I have tried to use the yaxistable TITLE option but the title text is added above each column of the table. I also tried to play around with a title2 statement by adding some leading blanks but that didn't work. Any other suggestions?
Thanks
Your best bet, in this case, would be to use SGANNOtation. I would add a TITLE2 with a title of " " to add some space after the real title. There is a simple example below. If you need more details on SGANNO, you can refer to a paper I did on annotation several years ago: https://support.sas.com/resources/papers/proceedings11/277-2011.pdf
Hope this helps!
Dan
title "This is a Title";
title2 " ";
data anno;
retain x1space "wallpercent" y1space "layoutpercent" function "text"
anchor "bottom" y1 100 width 40 textweight "bold";
label="Weight";
x1=116;
output;
label="Height";
x1=146;
output;
run;
proc sgplot data=sashelp.class sganno=anno;
hbar age / response=weight stat=mean;
yaxistable weight / stat=mean;
yaxistable weight / stat=median;
yaxistable height / stat=mean;
yaxistable height / stat=median;
run;
At least provide the code you are using currently. Otherwise we have to make so many guesses as to what you have that it is not practical. Better would be to provide example data in the form of a data step so we can actually test code against representative data.
The doc for the YAXISTABLE statement shows that you can use the TITLE= option on the YAXISTABLE statement. It also supports a LABEL= option.
Or are you saying that you want to use the current TITLE1 and TITLE2 values, regardless of what they are? In that case, you need to read dictionary tables to get the TITLE1 and TITLE2 into macro variables, then use those macro variables on the TITLE= or LABEL= option, as explained above. The details and an example are in the article "How to get the current TITLE in SAS."
Your best bet, in this case, would be to use SGANNOtation. I would add a TITLE2 with a title of " " to add some space after the real title. There is a simple example below. If you need more details on SGANNO, you can refer to a paper I did on annotation several years ago: https://support.sas.com/resources/papers/proceedings11/277-2011.pdf
Hope this helps!
Dan
title "This is a Title";
title2 " ";
data anno;
retain x1space "wallpercent" y1space "layoutpercent" function "text"
anchor "bottom" y1 100 width 40 textweight "bold";
label="Weight";
x1=116;
output;
label="Height";
x1=146;
output;
run;
proc sgplot data=sashelp.class sganno=anno;
hbar age / response=weight stat=mean;
yaxistable weight / stat=mean;
yaxistable weight / stat=median;
yaxistable height / stat=mean;
yaxistable height / stat=median;
run;
Thank you Dan. That worked!
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.