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!
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;
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;
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
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
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!
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!
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.
Ready to level-up your skills? Choose your own adventure.