Hi,
I would like to generate a report where titles and footnotes are repeated on each page outside the header and footer section.
I know that in oder to get the the titles and footers outsiide the headers and footer I can make use of BODYTITLE, however titles and foonote are not repeated on each page. I found though that ods.tagsets.rtf can acheive that ( more or less ).
*Lets first define my template:
libname templ 'C:\mydir\template';
proc template;
define style temp1/store=templ.temp1;
parent=styles.rtf;
end;
run;
Method ODS.RTF
This allows me to achieve the styles I wish (courrier new font size, no rules...). Titles and footnotes are not in headers anymore but
unfortunatly is not repeated at each page.
ods listing close;
ods path sashelp.tmplmst templ.temp1 (read);
ods rtf file='C:\mydir\demog.rtf' bodytitle style=first;
title1 'Table 1.1.1';
title2 'Demographics for all regions';
title3 'Study 7GFD-E04';
footnote1 j=l 'Note: first line note';
footnote2 j=l 'Note: second line note';
proc report data=sashelp.demographics nowd
style(header)=[frame=hsides rules=none];
column region name isoname pop popagr gni;
define region /group;
define name /display;
define isoname /display;
define pop /display;
define popagr /display;
define gni /display;
run;
ods rtf close;
ods listing;
Method ODS.TAGSETS.RTF STYLE=FIRST
This allows me to achieve the styles and Titles and footnotes are not in headers and are repeated at each page: I use the option (continue_tag="no)
ods listing close; ods path sashelp.tmplmst templ.temp1 (read); *ods tagsets.rtf file='C:\Mydir\demog.rtf' options(continue_tag="no") style=first; title1 'Table 1.1.1'; title2 'Demographics for all regions'; title3 'Study 7GFD-E04'; footnote1 j=l 'Note: first line note'; footnote2 j=l 'Note: second line note'; proc report data=sashelp.demographics nowd style(header)=[frame=hsides rules=none
]
style(column)=[frame=hsides rules=none fontfamily=courier];
column region name isoname pop popagr gni;
define region /group;
define name /display;
define isoname /display;
define pop /display;
define popagr /display;
define gni /display;
run;
ods tagsets.rtf close;
ods listing;
However my header of each column are in a box whil I just want them to framed by two horizonal lines (one above and below) so do not want to have vertical bar to seperate the column header as it look with this method.
The journal style could be use instead to have a frame for column headers to be sandwiched by two horizontal lines but I f you make the test ( replace style=first by style=journal) you will see that there are horizontal lines inserted in the middle of the reports several times ! I don't why...So journal is not a solution for me.
So to recap, ODS RTF was not a solution for me as I could not have title and footnotes repeated on each page outisde the headers and footer. Question : Is there a solution for ods.rtf to acheive this ?
Because ODS.RTF did not work, I used ODS.TAGSETS.RTF which worked almost..I have an issue with the headers of my column as they are in box instead of being between horizontal lines (frame=hsides)..Any clue on how to resolve this ?
Thanks in advance
saskap
Hi,
Well, what you are trying to do is to create sub headings, not titles or footnotes. The best bet is to do this via compute blocks and breaks:
proc report ...;
...
compute before / page;
line 'Title1';
line 'Title2';
endcomp;
compute after / page;
line 'Footnote1';
...
You can apply styles, e.g. borders, font etc. to these separately as well.
Hi RW9,
Thanks. Your proposal doesn't seems to work . I got the following error.
361 proc report data=sashelp.demographics nowd
362 style(header)=[frame=hsides rules=none fontfamily=courier]
363 style(column)=[frame=hsides rules=none fontfamily=courier];
364 column region name isoname pop popagr gni;
365
366 define region /group;
367 define name /display;
368 define isoname /display;
369 define pop /display;
370 define popagr /display;
371 define gni /display;
372 compute before /page;
----
79
76
ERROR 79-322: Expecting a STYLE.
ERROR 76-322: Syntax error, statement will be ignored.
373 line 'Title1';
374 line 'Title2';
375 endcomp;
376 compute after /page;
----
79
76
ERROR 79-322: Expecting a STYLE.
ERROR 76-322: Syntax error, statement will be ignored.
377 line 'Footnote1';
378 endcomp;
379 run;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE REPORT used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
I have tried to replace page by _page_ but issue is still there....
saskap
Yes, sorry, I gave you the wrong syntax there, this should demonstrate what I mean:
ods rtf file="s:\temp\rob\temp.rtf";
proc report data=sashelp.cars nowd;
columns _all_;
compute before _page_;
line 'Hello world';
endcomp;
run;
ods rtf close;
Ah, ok then. You may want to break your output up into pages and do each one at a time then, i.e. decide how many rows, or what defines a page, then print each one separately, have a look at this code which you can modify to your specific - i.e. add in the bodytitle option:
proc sql;
create table LOOP as
select distinct MAKE
from SASHELP.CARS;
quit;
ods _all_ close;
ods rtf file="s:\temp\rob\temp.rtf" style=statistical;
data _null_;
set loop;
call execute('title1 h=6pt font="SAS Monospace" "'||strip(make)||'";
proc report data=sashelp.cars nowd;
where make="'||strip(make)||'";
columns model type origin;
run;');
run;
ods rtf close;
You can add in your template below code and run and also use tageset not RTF. If you do not want empty row between title and footnote you can also use parskip both styles i given below
style table from table /
protectspecialchars = off
asis = on
cellpadding = 1pt
cellspacing = 1pt
borderwidth = 1pt
frame = hsides
rules = groups
;
style parskip /
fontsize = 0pt
;
if it is not working give me screen shot or attachment what exactly required.
Thanks Rajaram.
I used my ods.tagsets.rtf
code template :
proc template;
define style temp1/store=templ.temp1;
parent=styles.rtf;
style table from table /
protectspecialchars = off
asis = on
cellpadding = 1pt
cellspacing = 1pt
borderwidth = 1pt
frame = hsides
rules = groups
;
style parskip /
fontsize = 0pt
;
end;
run;
My code :
options nolabel orientation=landscape papersize=4 nodate nonumber;
ods listing close;
ods path sashelp.tmplmst templ.temp1 (read);
ods tagsets file='mydir\demog.rtf' options(continue_tag="no") style=first;
title1 'Table 1.1.1';
title2 'Demographics for all regions';
title3 'Study 7GFD-E04';
footnote1 j=l 'Note: first line note';
footnote2 j=l 'Note: second line note';
proc report data=sashelp.demographics nowd
style(header)=[frame=hsides rules=none fontfamily=courier]
style(column)=[frame=hsides rules=none fontfamily=courier];
column region name isoname pop popagr gni;
define region /group;
define name /display;
define isoname /display;
define pop /display;
define popagr /display;
define gni /display;
run;
ods tagsets.rtf close;
ods listing;
The result of this code is shown in attchment "CurrentTagset.png". The desired result is shown in attachment "wouldlike.png".
Currently I still have vertical border line in header's for each column.
Cheers
saskap
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.
Ready to level-up your skills? Choose your own adventure.