I use proc tabulate with multiple table statements, and each table statement repeats the title. Is there any way to suppress the 2nd and subsequent titles?
My code looks like this:
title .....;
proc tabulate;
class...;
var ...;
table ,,,,/condense;
table .../ condense;
table .../ condense;
run;
I end up with 3 titles while only need it once.
Thanks.
Hi:
Your only opportunity to change or suppress titles is between steps. You did not say what your destination of choice was (HTML, RTF, PDF, etc), One possible workaround is to use the PDF or RTF destination for your output. Only the title at the top of the page will show.
However, if you are using HTML or LISTING, you need a different workaround.That workaround -- is to have your first TABLE statement in a separate step with your first title; then after that first step, reset the title and have a second tabulate with all the rest of your TABLE statements.
These aren't very interesting tables since I used SASHELP.CLASS, but you should be able to run this code.
cynthia
** For PDF and RTF;
ods pdf file='c:\temp\multtab.pdf' startpage=no;
ods rtf file='c:\temp\multtab.rtf' startpage=no;
title 'First Title at top of page only';
proc tabulate data=sashelp.class;
class sex age;
var height weight;
table sex all,
height*(mean min)/condense;
table sex all,
weight*(mean min) / condense;
table sex all,
weight*(median max) / condense;
table sex all,
age=' '*height*mean /condense;
run;
ods _all_ close;
ods html file='c:\temp\multtab.html' style=sasweb;
ods listing;
title 'First Title';
proc tabulate data=sashelp.class;
class sex age;
var height weight;
table sex all,
height*(mean min);
run;
** reset title;
title;
options ls=200;
proc tabulate data=sashelp.class;
class sex age;
var height weight;
table sex all,
weight*(mean min) / condense;
table sex all,
weight*(median max) / condense;
table sex all,
age=' '*height*mean /condense rts=8;
run;
ods _all_ close;
How about adding :
title2 ' ' ;
I believe it's not possible with Proc Tabulate but it should be possible with Proc Report (using a LINE statement).
Hi:
Your only opportunity to change or suppress titles is between steps. You did not say what your destination of choice was (HTML, RTF, PDF, etc), One possible workaround is to use the PDF or RTF destination for your output. Only the title at the top of the page will show.
However, if you are using HTML or LISTING, you need a different workaround.That workaround -- is to have your first TABLE statement in a separate step with your first title; then after that first step, reset the title and have a second tabulate with all the rest of your TABLE statements.
These aren't very interesting tables since I used SASHELP.CLASS, but you should be able to run this code.
cynthia
** For PDF and RTF;
ods pdf file='c:\temp\multtab.pdf' startpage=no;
ods rtf file='c:\temp\multtab.rtf' startpage=no;
title 'First Title at top of page only';
proc tabulate data=sashelp.class;
class sex age;
var height weight;
table sex all,
height*(mean min)/condense;
table sex all,
weight*(mean min) / condense;
table sex all,
weight*(median max) / condense;
table sex all,
age=' '*height*mean /condense;
run;
ods _all_ close;
ods html file='c:\temp\multtab.html' style=sasweb;
ods listing;
title 'First Title';
proc tabulate data=sashelp.class;
class sex age;
var height weight;
table sex all,
height*(mean min);
run;
** reset title;
title;
options ls=200;
proc tabulate data=sashelp.class;
class sex age;
var height weight;
table sex all,
weight*(mean min) / condense;
table sex all,
weight*(median max) / condense;
table sex all,
age=' '*height*mean /condense rts=8;
run;
ods _all_ close;
An alternative approach might be to use PRETEXT style option in the first table. You can put the text just before the table but it will require a bit of coding to get things to look like an actual TITLE statement output.
Something like:
style=[pretext='My text instead of a title']
would go in the table options along with condense.
Good point. Pretext is one way to do it but you would have to be very careful to only put it on the first TABLE statement. PRETEXT will NOT work in the LISTING destination or OUTPUT window, however. And since CONDENSE is usually used in the LISTING destination, it might not work. But reading your post gave me another idea, too. ODS TEXT= for RTF, PDF, HTML -- would work instead of a TITLE statement. Again, ODS TEXT= doesn't work for the LISTING destination, but that would be an alternative too.
The only downside of using ODS TEXT= is that you have to do some more fiddling with the style to get it to look like a title, whereas with the first approach I sent, the TITLE will get styled appropriately without any further need to use a custom style template or style overrides.
cynthia
ods listing close;
option center nodate nonumber;
ods html file='c:\temp\use_text.html' style=sasweb;
ods pdf file='c:\temp\use_text.pdf' startpage=no;
ods rtf file='c:\temp\use_text.rtf';
title;
ods text='First Pseudo-Title Text string at top of FIRST page only';
proc tabulate data=sashelp.class;
class sex age;
var height weight;
table sex all,
height*(mean min)/condense;
table sex all,
weight*(mean min) / condense;
table sex all,
weight*(median max) / condense;
table sex all,
age=' '*height*mean /condense;
run;
ods _all_ close;
Thank you all for the suggestions. Cynthia's idea of repeating the proc tabulate statement after reseting the title is very easy and worked fine. This way I can use the formating of the original title statement.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.