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

Hello,

 

I am using PROC REPORT and ODS RTF to make a summary table. The table is a bit long and spans two pages on the RTF file. I want the table header to only appear on the first page and not the second page, and was wondering if there is a way to do that.

 

I noticed that Microsoft Word has an option to enable/disable "Repeat Header Rows" in the "Layout" tab, which is exactly what I need to disable in order to have the table header only appear on the first page. Does ODS RTF or PROC REPORT have a way to disable this "Repeat Header Rows" option?

 

 

This is some sample SAS code:

 

ods rtf file="Smoking.rtf";

proc report data=sashelp.heart(obs=90) nowd

style(report) = {cellpadding = 1.25pt cellspacing = 2pt frame = hsides rules = groups just=center};

column smoking;

define smoking/ display order=data;

run;

ods rtf close;

 

I would want to remove the "Smoking" header on the second page.

 

Thanks in advance for any help or tips!

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ
Thanks @Ksharp. That is the only way to suppress the headers on page 2 and all subsequent pages. It is the same method you need to use if you want a title on page 1, but not on any of the other pages. Given that it is much easier to turn the headers off in Word, that's what I'd recommend.
Cynthia

View solution in original post

10 REPLIES 10
Cynthia_sas
SAS Super FREQ
Hi:
There's not a way to suppress the headers for the second page the way you envision with PROC REPORT syntax. However, I note that when I open a multipage ODS RTF result file with Word, I can click the Layout tab in Word and suppress the Headers on page 2 and other pages.
Cynthia
Ksharp
Super User

There is a workaround way. But you would not like it .

 

ods rtf file="c:\temp\Smoking.rtf";

proc report data=sashelp.heart(obs=45) nowd
style(report) = {cellpadding = 1.25pt cellspacing = 2pt frame = hsides rules = groups just=center};
column smoking;
define smoking/ display order=data;
run;

proc report data=sashelp.heart(firstobs=46 obs=90) nowd noheader
style(report) = {cellpadding = 1.25pt cellspacing = 2pt frame = hsides rules = groups just=center};
column smoking;
define smoking/ display order=data;
run;
ods rtf close;
Cynthia_sas
SAS Super FREQ
Thanks @Ksharp. That is the only way to suppress the headers on page 2 and all subsequent pages. It is the same method you need to use if you want a title on page 1, but not on any of the other pages. Given that it is much easier to turn the headers off in Word, that's what I'd recommend.
Cynthia
Ksharp
Super User

Ha Cynthia, It is so interesting . Once I used "ods text=" , and Header of second page is disappeared .

 

ods rtf file="c:\temp\Smoking.rtf";
ods text='  ';
proc report data=sashelp.heart(obs=90) nowd
style(report) = {cellpadding = 1.25pt cellspacing = 2pt frame = hsides rules = groups just=center};
column smoking;
define smoking/ display order=data;
run;

ods rtf close;
Cynthia_sas
SAS Super FREQ
Hi:
If you change the statement to ODS RTF TEXT= (which is what you should do to change the RTF file), then it doesn't work anymore. I think this is a loophole that might not always work. Something to check with Tech Support I do not think this is the intended ODS RTF behavior with PROC REPORT.
Cynthia
ble9245
Fluorite | Level 6
Hi Ksharp,

An interesting solution/workaround you found! It works like you mentioned for this simple PROC REPORT, but it didn't work for me when I tried it on the PROC REPORT code I have. It caused my title to duplicate and the header on the second page was still there 😞

Thanks anyways!
Jianmin
Obsidian | Level 7

Hi @Ksharp , @Cynthia_sas and @ble9245 , 

 

Thanks for @ble9245 's question, even though I don't really understand why would anyone want a listing with only one header on the first page.  This would be the most simple SAS programing for that type of listing/table.   SAS ODS RTF/Proc REPORT goes beyond that.  It would assume one would like to have a table/listing with headers on every page, even though they can put a simple option for your request.   I don't really know if such option exists.  @Cynthia_sas is pretty good at this, and she would have told us such option. 

 

@Ksharp 's solution to use ODS TEXT=' ' was a success story by mistake:  SAS ODS RTF planned a perfect listing/table with headers on every page, by using a control word \trhdr.  But this control word works only in correct environment.  ODS TEXT= was poorly implemented in ODS, after it's done what it was supposed to do, it didn't provide a clean up to reset to the default paragraph property.  ODS RTF TEXT= is the correct one to use, as Cynthia pointed out, by providing a control word \pard and a new empty row.  So, if you compare the results of using ODS TEXT and ODS RTF TEXT, you will see that there is no space between the line by ODS TEXT=' ' and the line of 'Smoking', while there is an empty row between the line by ODS RTF TEXT='' and the line of 'Smoking', plus a control word \pard, which resets to default paragraph property, by Microsoft RTF specification. 

 

If I have to write some SAS programing for this listing, it would be something like this one: 

data _null_; set sashelp.heart(obs=90)  end=eof; 
file '~/Smoke.rtf'; 
if _n_=1 then do; %nt(0, w=6.5, o=p); 
&b_header; 
%nt(1, w=6.5); 
put &br "Page: \chpgn  of {\field{\*\fldinst  NUMPAGES }}" &e;
&e_header; 
%nt(1, s=40 40, h=1, w=6.5, hd=1, last=1); 
put &bc "{\fs28\b Listing 1: Smoking in Framingham Heart Study for the First 90 Observations}" &e; 
%nt(1, h=1, w=1, hd=1);    **** hd=0 will turn off the header for page 2 and after; 
put &bc "{\b Smoking}" &e; 
%nt(1, h=1, w=1, hd=0); 
end; 
put &bc smoking &e; 
if eof then do; %nt(100); end; 
run; 

The %nt macro code was published in 1998 in SAS Observations 13, and an RTF output from the above program is also attached.  

 

Thanks, 

Jianmin Long

 

Jianmin
Obsidian | Level 7

Hi @Ksharp , @Cynthia_sas and @ble9245 , 

 

Here is a link to the %NT macro, it was renamed as %RTF in the publication; 

http://ftp.sas.com/techsup/download/observations/obswww13/obswww13.pdf

 

Thanks. 

Jianmin Long

ble9245
Fluorite | Level 6

Hi Cynthia,

 

Thank you so much for your response and help with this. Turning the headers off in Word is the easiest and most reliable solution for me. If I do somehow find a way to suppress the header on the next page(s), I'll be sure to update my post.

 

Thanks again!

Ksharp
Super User
If I was right. You are using BODYTITLE option.

ods rtf file="c:\temp\Smoking.rtf" bodytitle;

Try to delete it and using ODS TEXT='xxxxxxx' to replace title .

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 10 replies
  • 3184 views
  • 1 like
  • 4 in conversation