Tuesday, August 23, 2011

Faster Log Notes

It seems as if log processing has been streamlined, so that log messages don’t take as much time. In the past, log messages slowed SAS down enough to become noticeable when a data step generates hundreds of log messages, but that seems to be less of an issue in SAS 9.3.

Sunday, August 14, 2011

An Issue With URLs

There is an issue with character encoding in the two SAS functions for URLs, URLENCODE and URLDECODE. URLs are uniform resource locators used on the Internet, such as web addresses. To work correctly, they need to be presented in the character encoding the Internet runs on, UTF-8. Yet SAS, as of release 9.3, has limited support for UTF-8, so the arguments to the URL functions might also be in the SAS session encoding.

To get around this potential stumbling block, there is a new system option in SAS 9.3 that lets you indicate the encoding of the argument to the URL functions. Set the option URLENCODING=SESSION if the argument is in the session encoding or URLENCODING=UTF8 if it is in UTF-8 encoding.

Friday, August 12, 2011

The 64-bit Observation Counter

The EXTENDOBSCOUNTER option is mentioned in the announcement for the new edition of Professional SAS Programmer’s Pocket Reference, and that made me realize I needed to write a post to explain what it is.

It is no longer a gee-whiz moment when a data table exceeds 2 billion rows. And with the computers of 2011, it is not such a big deal to be processing that many observations in a SAS program. So within a few years, it would have started to seem quaint that SAS can count observations only up to about 2 billion.

That is why SAS set its sights on a new observation counter that can count observations up to 9 quintillion. The new 64-bit observation counter is available in SAS 9.3, but it is not the default because it is not compatible with any prior SAS release. If you are working with data that could run into the billions of observations, though, you would do well to start using the new expanded observation counter as soon as you complete the transition from SAS 9.2 to SAS 9.3.

All this requires is the EXTENDOBSCOUNTER=YES option in the LIBNAME statement for the library. To use a 64-bit observation counter on an individual SAS data file, write the option as a data set option when you create the file.

The 64-bit observation counter will become the norm, I am sure, at some point in the future when the chances of encountering SAS 9.2 and earlier SAS releases become relatively slight. At this point, though, it is important to note that the EXTENDOBSCOUNTER=YES option makes SAS data sets incompatible with SAS 9.2, so it isn't the right move in a company that is still using SAS 9.2 on some machines. At worst, it would force you to make copies of SAS libraries in SAS 9.3 before you could use them in SAS 9.2 — not a big deal if there are just a few million observations, but a process you would rather avoid if the observation count is closer to a billion.

Professional SAS Programmer’s Pocket Reference: A Small Book for Working With Big Data

A new edition of Professional SAS Programmer’s Pocket Reference covering SAS 9.3 will be available in September 2011.

“Big analytics” is one of the themes of SAS 9.3, released one month ago on July 12. SAS was always noted for its ability to process large-scale data, and SAS 9.3 adds new capabilities to make it more nimble in getting results from the “big data” that businesses increasingly rely on for a competitive edge.

Author Rick Aster has responded to this theme of a nimble approach to big data — and to the new features in SAS — with Professional SAS Programmer’s Pocket Reference, 6th edition. This new edition of Aster’s popular compact reference guide for SAS is updated with the new features of SAS 9.3. At the same time, it is almost 20% lighter than the previous edition, in spite of having the same number of pages and the same amount of content as before. The lighter weight, made possible by improved paper and design, is an advantage for SAS professionals who increasingly find themselves going from one place to another in the course of their work in SAS.

The new 6th edition of Professional SAS Programmer’s Pocket Reference covers new features in SAS 9.3 that have to do with big data, such as the EXTENDOBSCOUNTER option that makes it easier to manage files that have more than 2 billion records.

The book also covers new SAS 9.3 features that allow a more modular approach to programming, easier internationalization for programs that are used in multiple countries, and new ways to use SAS on the Internet.

Publisher Breakfast Books hopes to have the new book ready for September 12, when the first of the fall SAS conferences gets underway.

Catalog page:


SAS is a registered trademark of SAS Institute Inc.

Tuesday, August 9, 2011

Formatting Long and Short Durations With a Picture Format

Two new picture directives are specifically designed for formatting time durations. This allows you to use the FORMAT procedure to create formats to show time durations even if they are particularly long or short periods of time.

Using a picture format for a time duration was somewhat perilous in previous SAS releases, because the time picture directives were oriented toward time of day. If a duration ran more than 24 hours, the picture format would neglect the whole days that had elapsed and report only the fractional days. A time of 5 days, 5 seconds would show up just as 5 seconds.

That is no longer a problem with the %n picture directive, which fills in the previously missing days. A picture such as "%n:%H:%M:%S" gives you the duration in days, hours, minutes, and seconds.

For shorter time periods where fractions of seconds matter, the %s picture directive provides the fractional part of the seconds value, including the decimal point.

Sunday, August 7, 2011

Using a Function As a Format

A subtle change in the FORMAT procedure in SAS 9.3 makes it possible to use a function as a format.

SAS already allowed you to use another format within a value format. For example, you could create a format that provided special formatted values for the numbers 1 and 2, then formatted all other values with the BEST format. The syntax for this involves writing the format in brackets, for example:

other = [best8.]
To pass the range off to a function instead, write the function name and parentheses inside the brackets. The example in Base SAS 9.3 Procedures Guide suggests creating a function called QFMT (in the FCMP procedure), then using it in a value format, also called QFMT, and defined in this statement:
   value qfmt 

There is only one range, OTHER, in this format because all formatted values are generated by the function.

This approach essentially makes it possible to use all the computational possibilities of the FCMP procedure, but them access the resulting value as a format.

Thursday, August 4, 2011

Deleting Macros in SAS 9.3

In previous SAS releases, it was possible to delete a macro after you had defined it, but you had to know the name of the WORK.SASMACR library, the entry type of a macro entry, and the workings of the PROC CATALOG step in order to do the deletion. SAS 9.3 simplifies the process of deleting a macro with a new macro statement, the %SYSMACDELETE statement.

Write the macro name in this statement, and the macro is deleted. For example, to delete the RESETP macro, write:


If you are not sure the macro exists, use the NOWARN option to delete it with no warning message if it turns the macro does not exist: