BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PTD_SAS
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ


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

6 REPLIES 6
Ksharp
Super User

How about  adding :

title2 ' ' ;

Patrick
Opal | Level 21

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

Cynthia_sas
SAS Super FREQ


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;

ballardw
Super User

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.

Cynthia_sas
SAS Super FREQ

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;

PTD_SAS
Obsidian | Level 7

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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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