BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I'm trying to create a cover sheet to accompany a proc report. I can manage with a ods and a data _null_ statement but the output is in default sas font and is ugly. Is there any way to pass ods style option within the data _null_ step?

Here is what I'm working with.

ods pdf file = '~/.pdf';
*Cover page;
data _null_;
file print;
put #10 @5 "Report One"
run;
*Report tables;
proc report;
...
run;
ods pdf close;
2 REPLIES 2
Cynthia_sas
SAS Super FREQ
Hi!
Generally, I do not use data _null_ for a cover sheet.
Here's what I usually do:
[pre]
data coverpg;
length rline $75;
rline = 'Report One';
output;
run;

options topmargin=5in;
ods pdf file='plus_cover.pdf';

proc report data=coverpg noheaders nowd
style(report)={rules=none frame=void cellspacing=0};
column rline;
define rline /display ' '
style(column)={font_size=16pt font_weight=bold};
run;

options topmargin=.25in;
ods pdf;
proc report .....;
** code for rest of report;
run;
ods pdf close;
[/pre]

The nice thing about this approach is that you get to use the STYLE= statement level overrides for your report line and since every proc report step starts a new page, the cover page is on a page by itself and you use topmargin to position the title line as far down on the page as you want (this may take some fiddling to get the placement you want. (Also, I typed this code from memory, as I am on my daughter's computer right now. so although I've used the technique, I have not tested the above code snippet before posting.)

If you really wanted to go with a DATA _NULL_ approach, the way to apply style to a text string in a DATA _NULL_ is through the use of ODS ESCAPECHAR...so for example, in you data step, you might modify your program as shown below and then you would have to make sure that ods pdf 'knew' that you were using the tilde as the escapechar by issuing an ods escapechar statement at the beginning of your step:
[pre]
ods pdf file='xxx.pdf';
ods escapechar='~';

**data _null_ code that uses the escapechar;
** including;
length rline $75;
rline="~S={font_size=16pt font_weight=bold}Report One";
file print ods;
put @1 rline;
** rest of data step code;

proc report code;
ods pdf close;
[/pre]

So you really have 2 different choices..a data _null_ choice (with modifications to direct the output to ODS)and a proc report choice. There are some other issues with the data _null_ sample code that you posted, however. The "old/classic" way of using FILE PRINT/PUT #10 @5, etc. still works quite nicely with the LISTING destination, but is not as friendly when used with ODS. You put it very succinctly when you said that the output was ugly.

The "new" syntax for ODS and FILE PRINT ODS falls along these lines:
[pre]
data _null_;
set xxx;
file print ods;
put _ods_;
run;
[/pre]

But, is is harder to suppress the headers and table lines with the default table template that's used with data _null_ and ODS. (not impossible, just harder because you have to create your own table template to use with data _null_.) So that's yet another reason why I like to use PROC REPORT for this sort of thing.

cynthia
deleted_user
Not applicable
That did it. Thanks.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 2 replies
  • 1084 views
  • 0 likes
  • 2 in conversation