Help using Base SAS procedures

Proc Tabulate multiple titles

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

Proc Tabulate multiple titles

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.


Accepted Solutions
Solution
‎04-27-2012 09:49 AM
SAS Super FREQ
Posts: 8,743

Re: Proc Tabulate multiple titles


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;

View solution in original post


All Replies
Super User
Posts: 9,681

Re: Proc Tabulate multiple titles

How about  adding :

title2 ' ' ;

Respected Advisor
Posts: 3,892

Re: Proc Tabulate multiple titles

I believe it's not possible with Proc Tabulate but it should be possible with Proc Report (using a LINE statement).

Solution
‎04-27-2012 09:49 AM
SAS Super FREQ
Posts: 8,743

Re: Proc Tabulate multiple titles


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;

Super User
Posts: 10,500

Re: Proc Tabulate multiple titles

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.

SAS Super FREQ
Posts: 8,743

Re: Proc Tabulate multiple titles

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;

Contributor
Posts: 71

Re: Proc Tabulate multiple titles

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 4380 views
  • 4 likes
  • 5 in conversation