ODS PDF destination in SAS 9.4: Come take a look under the hood!

If you have programmed with SAS in the last 15 years, you have probably had a reason to share your SAS results in PDF format. The ODS PDF destination, much like a well-designed car, has evolved over the years, offering progressively nicer features like security, enhanced image formatting and embedded fonts. I think you’re going to like what SAS 9.4 has to offer!

Let’s discuss three key SAS 9.4 improvements to this beloved, reliable and top rated ODS destination:

  • Pearl default style
  • ODS LAYOUT statement
  • ODSLIST and ODSTEXT procedures

ODS PDF’s new default style: Not just a pretty paint color.

Just like car manufacturers, the ODS developers have improved the “look and feel” of the PDF destination in SAS 9.4 by updating the default style. Styles.Pearl, the new default style for ODS PDF and ODS PRINTER,  is designed with a more modern feel. The headers are no longer shaded, the borders are lighter and we think you’ll agree the results are much more appealing. Here’s a screen shot showing sample PROC PRINT results comparing the new default style, styles.Pearl, with the earlier default, styles.Printer:

Illustration showing differences in SAS 9.4 default ODS Styles.PEARL and previous default Styles.PRINTER

ODS LAYOUT: Production status with robust documentation

The ODS LAYOUT feature, which allows the precise placement of SAS output on a PDF page, was introduced in SAS 9.2. However, it held so much power and required so many feature improvements, it was released in preproduction status. Since that time the SAS programming community has offered feedback on its performance and features, leading to the SAS 9.4 release where the destination is offered with two distinct models: GRIDDED and ABSOLUTE, both of which offer robust “owner’s manuals”.

We think the ABSOLUTE model will be the most popular. You can use it to place tables and images side by side, stack them top to bottom and even overlay output in your PDF files, and works to create output placed on a single PDF page.  The GRIDDED model is more useful when using BY-group data and/or creating multi page output.

The ABSOLUTE LAYOUT syntax uses a pair of ODS LAYOUT statements (ODS LAYOUT START and ODS LAYOUT END) to define the area on the page to which you will write ODS REGIONs.  ODS REGION statements define the location and size of regions to which you will write tables, text or images. Both statements use the X= argument to define the horizontal “start” position, and Y= to define the vertical start position of your output. If you do not use either of these, the output starts in the upper left corner (0,0). Height= and Width= arguments can be used on both statements to control the size of the layouts and regions.

Here is sample code for defining a sleek layout page within your ODS PDF destination:

  • Create a PDF file with FILE=, turn off the bookmark/table of contents with NOTOC, and with NOGTITLE make all Graph titles part of the PDF file, instead of embedding them in the Graph images.
    ods pdf file="file.pdf" notoc nogtitle ;
  • Define a LAYOUT that is 7.25 inches high and 10.5 inches wide.  The keyword ABSOLUTE is not necessary as it is implied if neither the COLUMNS= nor the ROWS= option is used. Previously we have set the system option ORIENTATION= to LANDSCAPE on an OPTIONS statement and set a Title and Footnote, whose text will be placed outside the layout.
    ods layout start height=7.25in width=10.5in ;
  • Define the first REGION. The region is placed inside my layout, starting .75 inch from my top margin (y=.75in) and one inch from my left margin (x=1in). This region is allocated 3.5inches of space across my page (width=3.5in).
    ods region x=1in y=.75in width=3.5in ;

The ODS LAYOUT and REGION statements used above are part of Sample 55808.  We’ll use the full code to generate the following output from SAS 9.4, and I’ll explain how to assemble all the pieces using other new features in SAS 9.4:

SAS 9.4 ODS output using ODS LAYOUT statement

PROC ODSTEXT: easily insert paragraphs of text

The ODSTEXT procedure helps us format paragraph text that would previously have been written with DATA _null_ / FILE PRINT logic or ODS <destination> TEXT= syntax. However, neither of these methods allow for elegant style control and line spacing, nor do either of those strategies integrate well with the table of contents.  Now using PROC ODSTEXT, we can format paragraphs of text (or just single words if preferred!), with ease.

Here’s the first PROC ODSTEXT code used in our screen shot shown above:

proc odstext;
    p "The ODSTEXT procedure offers a powerful tool for inserting paragraph style text into your ODS destinations. "  / style=systemtitle;
    p  "The ODSTEXT procedure allows us to: format text with style control offered with the statement option style=,  use data sets, and add bullets."  / style=systemtitle;
    p '  ';
    p "A close sibling is PROC ODSLIST, used to generate the following bulleted list of improved ODS PDF features:" /  style=header;

Here are the results:

PROC ODSTEXT output showing three sizes and

PROC ODSLIST: easily create bulleted lists

Closely related to the ODSTEXT procedure is PROC ODSLIST, which allows us to create nicely formatted, indented and bulleted lists from a SAS dataset. Here’s an example:

 proc odslist data=features;
   item feature /style={bullet="disc"};

Here are the results:

There’s an added bonus in SAS 9.4: the ODSLIST and ODSTEXT procedures can be used in ANY of the non-LISTING ODS destinations.  Try them out in ODS POWERPOINT and ODS RTF too!

Adding the bar chart to our layout

The image in our PDF file is created with the PROC SGPLOT and highlights a feature new in SAS 9.4, the SYMBOLCHAR statement.  The data and program are described in Sample 54315 and a recent Problem Solvers blog. The key to sizing and inserting the output in the upper right corner of our PDF file is specifying the following ODS REGION statement and the ODS GRAPHICS statement height= option before the PROC SGPLOT code.

ods region x=4in y=.5in ; 
ods graphics on / reset noborder height=3.5in;

Adding the table to the PDF

The bottom table is created by PROC REPORT along with some “power assist” from PROCs ODSTEST and FORMAT. This region is defined only with a Y= specification as I want REPORT’s table to take up the width of the entire region. The REPORT table will be centered by default, but ODSTEXT= will not, hence the j=c style override.

ods region y=4in; 

proc format;
value myfmt low-40="^{style [foreground=red] ^{unicode 2193} "
           40-high="^{style [foreground=green] ^{unicode 2191} ";

proc odstext ;
   p " ";
   p "A subset of SASHELP.CARS where MPG_HIGHWAY is greater than 40 " / style={font=(", Albany",10pt,bold) just=c};

proc report data=sashelp.cars(where=(mpg_highway gt 40 and cylinders eq 4)) spanrows
style(report)={posttext="^{style [font_weight=bold] PROC FORMAT uses inline formatting and the Unicode style function to differentiate models based on the combined MPG}" };
col make model mpg_highway mpg_city avg type enginesize horsepower drivetrain;
define make / order;
define avg  / computed "Combined MPG" format=8. style(column)={posttext=myfmt.};
compute avg;

Here are the results:

Using ODS LAYOUT feature to create and place a PROC REPORT table
We “put the brakes on” by closing the LAYOUT and the PDF destination:

ods layout end;
ods pdf close;

I hope you have enjoyed “kicking the tires” on my favorite destination. Are you excited about getting this new and updated model? If so, give your SAS dealership (ahem, representative) a call and upgrade today!

Please read the fine print:

If you have been an intrepid ODS LAYOUT coder prior to SAS 9.4, you are likely to see different results from your ODS LAYOUT/REGION statements when you move to SAS 9.4. If using the legacy style, styles.printer, does not correct the results, use Scott Huntley’s paper “An Insider’s Guide to ODS LAYOUT Using SAS® 9.4” . It is an excellent resource for coders moving ODS LAYOUT code from previous releases.

If you are moving from a SAS release prior to version 9.2, Scott and I wrote this paper “Getting the Right Report (Again): Your Compatibility Guide for ODS PDF 9.2” to discuss changes that took place for ODS PDF in that version.

Scott and Woody Middleton introduce you to the new features for ODS PDF in SAS 9.3 in "A Different Point of View with ODS PDF in SAS®9.3".

SAS has provided printable tip sheets for ODS PDF, ODS LAYOUT, PROC ODSTEXT, PROC ODSLIST, ODS GRAPHICS and more.

Post a Comment

PharmaSUG 2015: Transformation is a key topic

PharmaSUG 2015 logo with sea turtle image and Orlando 2015Last night over 640 SAS users from 12 countries met in Orlando for a great opening session at PharmaSUG 2015. Elizabeth Dennis from EMB Statistical Solutions and Syamala Schoemperlen from Alcon, a Novartis Company are this year’s co-chairs. They lined up a wonderful venue as well as content for the conference. Read More »

Post a Comment

SAS Visual Analytics:  Localize your reports to support multiple languages!

Do you support a multilingual reporting audience? This is a fast-growing requirement for many of you,  and now your SAS Visual Analytics reports can be easily configured to support any number of languages.

From SAS Visual Analytics Designer, there is an option under the File menu called Localize Report. This brings up the Localize Report Text dialogue. This dialogue lists all of the available items and their values that can be translated into a different language. Keep in mind that you cannot translate the data surfaced in the report, but you are able to translate almost all text that appears in the report, such as object labels, tooltips and other descriptive text. Read More »

Post a Comment

PharmaSUG 2015—the lucky 22 gear up to attend

PharmaSUG 2015 logo with sea turtle image and Orlando 2015Actually, luck had little to do with it. The twenty two recipients of Student Scholarship and Junior Professional Awards are attending the Pharmaceutical Industry SAS Users Group (PharmaSUG) from May 17-20 because of their qualifications. This marks the fifth year that PharmaSUG has offered these special programs, which are funded by SAS and managed by PharmaSUG volunteers Richard Allen and Ellen Brookstein. I spoke recently with Ellen to learn more. Read More »

Post a Comment

Weather forecasting with SAS-generated Google maps

Photograph of Northern Cardinal in snow stormThe Earth is flat. At least as far as Google maps are concerned. Don’t just take my word for it though. Bring up a Google map onto your computer screen and make sure of this with your own eyes.

Now, when you got comfortable with that revolutionary concept, here’s another one: weather is weird. You’d know this firsthand if you live in the East of the United States, where the first week of March brought almost a foot of snow and record-low temperatures well below freezing (like 10-15 F°). This didn’t seem to concern the cardinal that made its way into my backyard igloo during the March blizzard in misguided hopes of Spring.

Combining weather and Google maps seems to be so natural since weather is a property of a particular location at a given time. Of course, weather changes in time, but if we can connect and stream weather data into a location on the map, wouldn’t that be cool?  Whether you want a broad, synoptic view of the weather forecast over a country or a continent, or you are just interested in the current weather conditions in a particular locale, I see possible business applications in any field that relies on weather forecast—agriculture, aviation, tourism, vacation and trips planning to name a few. This application would also provide access to the weather information around the globe. Read More »

Post a Comment

SAS administration and architecture—highlights from SAS Global Forum 2015

I was privileged with the opportunity to present a couple of papers at SAS Global Forum 2015 in Dallas, Texas this year.  While there, I was also excited to attend presentations with new and inventive approaches for working with the administration and architecture of SAS solutions. This is a collection of just a few of my favorites. Read More »

Post a Comment

Can tweets reveal the mood of the #Ebola outbreak?

Less than a year ago, the country’s attention was on Dallas after the first Ebola patient died. Not only is that where this project begins, but also where it was presented at SAS Global Forum in Dallas.

Sharat Dwibhasi and his classmates Dheerj Jami and Shivkanth Lanka from Oklahoma State University analyzed the sentiment of the Ebola outbreak using tweets. Read More »

Post a Comment

SAS Global Forum 2015 – a glimpse into upcoming SAS releases

Hadoop, in-memory analytics, the Internet of Things (IoT), machine learning, data visualization— topics that are dominating the analytics airwaves. SAS is innovating in all these areas, rapidly developing new products and functionality to meet the needs of today’s analytic environment.

During this year’s Technology Connection session, SAS Global Forum 2015 attendees got a glimpse into SAS R&D’s 18-month plan, which is driven in large part by initiatives like Hadoop and IoT that are changing the way you can manage and share data.  Here are just a few of the new and enhanced products slated for upcoming SAS releases. Read More »

Post a Comment

Converting variable types—use PUT() or INPUT()?

How many times have you had a need to convert between variable types such as converting character to numeric or numeric to character?  For example, what if you have a character variable with numeric values but you need to perform some calculations?  Or, if you have a numeric variable but you need to concatenate it to a character variable?  If you are like most SAS programmers, you need to use PUT() and INPUT() at least once to complete these tasks. Read More »

Post a Comment

New changes for SAS users group leaders

IMG_1696SAS Global Forum provides a perfect opportunity for SAS users group leaders from across the country to meet in-person to share best practices and new ideas.

This year’s SAS users group leaders link-up event was led by Melissa Perez – the new users group programs manager at SAS. She talked about her new team and how they are dedicated to coming up with better ways to provide resources and support to users group leaders. Read More »

Post a Comment