ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
Sunil_chakri
Calcite | Level 5

Hi All,

This is my first post in the group. Please excuse if any mistake.

We have a macro which generates table output(multiple pages). Is there any way can we get a default header and footer on all pages please.. inODS? Come to know we can create a word file manually with header and footer  and by using  header option in ODS header="path of the file \filename.docx".

For Ex: ods rtf file="&tabout." header="C:\Temp work\header.docx" ;

 its throwing me error:

! header="C:\Temp work\header.docx" ;
------
180
ERROR 180-322: Statement is not valid or it is used out of proper order.

1 REPLY 1
ballardw
Super User

If by "header" and "footer" you mean the RTF header and footer locations then you may want TITLE, for header, and FOOTNOTE, for footer, location text.

That would look like (dummy code partially as we have no idea what your output generator looks like):

 ods rtf file="&tabout." 

Title1 "C:\Temp work\header.docx";
Footnote1 "This goes in the footer";
Proc print data=sashelp.class;
run;

ods rtf close;
title; footnote;

ODS destinations like RTF and PDF have additional options that affect how title and footnotes may be placed in a document.

SAS allows up to 10 Title and Footnote statements. These stay in effect until cancelled or replaced. This allows you to have an example, like the document name as title1 placed on each page and then using title2 (and/or 3,4, etc) to provide additional information such as subject or project details for only part of the output.

You cancel a title or footnote by using a statement without any text. So if you have 5 currently defined title statements and issue

title3;

in your code then from that point, until they are redefined, titles 3, 4 and 5 have been cleared.

Note that my example clears all the title and footnote definitions after the document is written. Title is equivalent to Title1 and Footnote to Footnote1 for that purpose.

There are options that control appearance of title text and your ods style in effect for the document will set some things like font, font size, font weight (bold/normal) or style such as italic. You can override such if needed.

 

I suggest not naming files with a DOCX extension that are actually RTF. Microsoft is getting picky about such false names not matching content. You may be better off with an RTF extension, which will open in word processors by default. If needed do a File Save As to Docx. Or try the ODS WORD destination though that is still pre-production (means may have issues).

 

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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
  • 1 reply
  • 1161 views
  • 1 like
  • 2 in conversation