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
... View more