BookmarkSubscribeRSS Feed
tropsyx
Calcite | Level 5
Hi,
I am a novice user of SAS. My problem is to add a HEADER to my report, without using the TITLE function.

Any suggestions?

Best,
Valentin
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Valentin:
This may turn out to be a question for Tech Support, but one possible answer is to use the ODS TEXT= option.

The answer also depends on what you mean by a "HEADER". There are several different kinds of headers you could be thinking of -- 1) a pseudo-title that sits outside the table boundaries, in some destinations looks just like a title (ODS TEXT= does this); 2) a header that sits on top of a table, but inside the table box (PROC REPORT or table templates do this) ; 3) a header area that "belongs" to a destination, such as text that goes in the section of an HTML file or the kinds of headers and footers you can have in Microsoft Word or Excel (either of these are possible, but require more advanced syntax.)

The code below shows what you can do with PROC REPORT and the TEXT= option in ODS HTML. After you run this code, you will notice that the header and the footer from the COMPUTE blocks are within the boundary of the table. Compare this to the text string from the TEXT= option that will sit above the table if you put it before your PROC and sit under the table if you put it after your PROC. And, you can choose just about any PROC when you use the TEXT= option (not just REPORT).

However, the default justification for the TEXT string is left justified, which I have fixed in my ODS HTML code using HTML tags. If you are not interested in HTML, then you would have to use other techniques to justify the text and/or change the font. These techniques take us into more complicated ODS territory, because you either have to use ODS ESCAPECHAR to send style attributes for this TEXT= to ODS or you have to make a custom style template that defines the presentation attributes of the user text.

This is the point where I say that how you add a header depends on many different variables, such as:
--What do you mean by a "HEADER"?
--What is your destination of choice (RTF, PDF, HTML)?
--What is your procedure of choice (REPORT, GLM, MEANS, SAS/Graph)?
--What is your interface to SAS? (Display Manager, EG, batch programs)
--What is the final purpose of the document??
For example, you want RTF, because you need to assemble a Word document from many disparate SAS reports, so there's no point in learning how to format the user text for RTF because you will be touching the document anyway.

OR -- you need PDF or HTML output and so you MUST learn how to change the header because the users will NOT be able to change the output file after it's created.

OR -- you want to create files that you can open with Excel and you want your HEADER to be put into the PRINT PREVIEW HEADER of the Excel spreadsheet and not into the body of the document/spreadsheet (The ExcelXP tagset can do this)

The people with the best skills to gather all this information and help you decide on the right course of action are in Tech Support. You can find out how to contact them by going to the site below:
http://support.sas.com/ctx/supportform/index.jsp
Good luck!
cynthia
[pre]
*** the code;
ods html file='header2.html' style=sasweb;
ods html text='

From ODS TEXT Statement

';
proc report data=sashelp.class nowd
style(header)={background=purple
foreground=white};
column ('Spanning Header 1' name age height weight);
compute before _page_ /
style={background=pink};
line 'Line from Compute Before _Page_';
endcomp;
compute after _page_/
style={background=yellow};
line 'Line from Compute After _Page_';
endcomp;
run;
ods html close;[/pre]

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 2979 views
  • 0 likes
  • 2 in conversation