Tuesday, October 2, 2012

The CHAR and FIRST Functions

Here is a quick clarification of the CHAR and FIRST functions, which apparently are still being discovered by SAS programmers.

These two functions return individual characters of a character value. They work the same as the SUBPAD function, but while the SUBPAD function can return a substring of any length, the CHAR and FIRST functions can only return a single character. As with the SUBPAD function, the return value is a space (or blank) if no character is available to return.

These functions are defined with a length of 1, so they may use less memory than the SUBPAD function. The FIRST function returns the first character of the string argument. The CHAR function returns one character from the position indicated in the second argument. If STRING is a character variable containing a character string, these statements demonstrate the use of the FIRST and CHAR functions:

   length first_character second_character $ 1;
   first_character = first(string);
   second_character = char(string, 2);

In the CHAR function as in the SUBPAD function, if the position argument is not an integer, the function truncates to form an integer value to use.

Wednesday, September 12, 2012

The SAS Analytical Products 12.1 Release, and Its Implications for Base SAS

There is a new SAS analytics release, collectively identified as SAS Analytical Products 12.1. This is a departure from past practice, in which SAS analytics products used the same version numbers that SAS had. As SAS/STAT 12.1 User’s Guide explains,

In previous years, SAS/STAT® software was updated only with new releases of Base SAS® software, but this is no longer the case. This means that SAS/STAT software can be released to customers when enhancements are ready, and the goal is to update SAS/STAT every 12 to 18 months. To mark this newfound independence, the release numbering scheme for SAS/STAT is changing with this release. This new numbering scheme will be maintained when new versions of Base SAS and SAS/STAT ship at the same time. For example, when Base SAS 9.4 is released, SAS/STAT 13.1 will be released.

Similar statements are found for other products. The new release includes SAS/ETS, SAS Enterprise Miner, SAS/QC, SAS/IML, SAS/IML Studio, SAS/OR, SAS Simulation Studio, SAS Forecast Server, SAS Model Manager, SAS Sentiment Analysis, SAS Content Categorization, and SAS Text Miner, all now numbered 12.1.

Users of these products will be interested in the many new features, especially the new regression procedures introduced in SAS/STAT. I am also interested in the implications for base SAS, though these are more speculative in nature.

Most obviously, the statement refers to “Base SAS 9.4” as a known future event. This is not the first official mention of 9.4 that we have seen, but I take it as the most definite indication to date that a revision to base SAS is in the works.

The wording also suggests that the release of SAS 9.4 is not imminent, that is, not likely to be seen in the next 12 months. More broadly, the new version numbering scheme suggests that base SAS releases may become less frequent, perhaps occurring in a 2- to 5-year cycle, while analytics releases become more frequent, happening almost every year.

My take on this divergence in SAS development is that the core technology in SAS is now successfully object-oriented and abstracted, a change that SAS identified as a strategic direction in the late 1990s. This would imply that an update to SAS would no longer require an update to every procedure. You could change the SAS version without reinstalling all of the procedures. Or, you might be able to use a SAS procedure with a SAS version other than the one it was created for. This is something a few of the more adventurous SAS users have been attempting, and sometimes reporting some success with, in recent years.

Getting more speculative now, I am hoping this is a sign that SAS is getting closer to the more flexible approach to data that I have been waiting for. Closer, perhaps, but not there yet. I have always assumed the new data-handling features were targeted for SAS 10; the changes would be too fundamental in a technological sense to roll into a second-level release number. The announcement of SAS Analytical Products 12.1 tells us that if indeed SAS 10 exists, we will have to wait at least several more release cycles to see it.

Wednesday, August 22, 2012

SAS 9.2 Dominates Latest Chart

The latest report on 10 most viewed SAS Documentation titles shows that SAS 9.3 is far from overtaking SAS 9.2 as the default SAS release. The top 10 includes nine documents for SAS 9.2 and none for SAS 9.3.

This doesn’t mean no one is using SAS 9.3 — obviously, many people are — but the number of people using SAS 9.2 must be at least twice as high for it to hold a lockout on the top 10.

Monday, July 2, 2012

Professional SAS Programming Shortcuts Approved for Printing

The 3rd edition of Professional SAS Programming Shortcuts got final editorial approval today, which means it is on its way to be printed. If all goes well, the new book will be available for purchase next month.

Monday, May 14, 2012

Professional SAS Programming Shortcuts, Finished

Professional SAS Programming Shortcuts has come together much the way I envisioned it in January, based in large part on the reader requests and suggestions I received at that time. In the end, it is about 25 percent different from the previous edition. I put the finishing touches on it this afternoon — and when I say “finishing touches,” I mean the index has been compiled, typeset, and incorporated into the final page layout document.

The book now goes off to the big publishing machine for proofreading and whatever other small, late improvements can be found over the next month or so. And after that, I am hoping the new edition (the 3rd) can be in print in time for the textbook season in August. In any case, I will make sure that any student who needs to get a copy of the book in August or September will be able to do so. I will have more to say about the new edition when the release date is closer.

Thursday, May 10, 2012

SAS 9.3 Syntax Index

A new feature on the SAS support site makes it easier to look up SAS syntax. This is the SAS 9.3 Syntax Index, which lists the important keywords of SAS so that you can quickly look up the syntax models and rules you need.

You have to know the name of the statement, function, option, or other SAS feature to look it up, though often it is easy enough to guess. Let’s say you’re hoping to find a function to compute the distance between U.S. ZIP codes. Maybe the name starts with ZIP. In the SAS 9.3 Syntax Index, click the letter Z, scroll down till you get to ZIP, and you find, among other things, “ZIPCITYDISTANCE function.” Is that the function you want? Click the list item, and the syntax entry appears in the right side of the window.

Thursday, May 3, 2012

SAS 9.3 Adoption

As the echoes from the conference in Orlando die away, my sense from the chatter surrounding that event is that it is still early in the adoption cycle for SAS 9.3. Some users were hearing about it for the first time at SAS Global Forum, while more had it, or thought they did, but had not yet evaluated it in any serious way. And some users, of course, have been using SAS 9.3 for some time now.

Between now and next year at this time, I expect most of the large sites will have evaluated SAS 9.3 and begun making it available to ordinary users.

Tuesday, January 24, 2012

SAS on 64-Bit Ubuntu VM

From atomicvindaloo.com, here is a scenario that may interest some readers: installing SAS 9.3 on “a 64-bit Ubuntu in a Virtualbox machine running on 32-bit XP.”

Thursday, January 19, 2012

Professional SAS Programming Shortcuts Changes and Proposed Table of Contents

I heard from the warehouse a week ago that the last box of Professional SAS Programming Shortcuts had shipped out. Don’t worry, there are still copies in the channel, available for purchase at the usual places, and in a pinch, there is a small pile of slightly hurt copies at the publisher. But with the current edition sold out, at least at the publisher, it made me think more urgently about what could be different in the next edition of the book.

I took a look at the book, and a few of the examples and techniques that were current in 2005 will have to be taken out now. To begin with, the Global Distances example is no longer needed now that SAS has added a function to do the same thing. And there are other examples scattered throughout the book that are in the same boat. It just isn’t a surprise when SAS introduces new functions and other features to make our lives easier.

I also think it is about time to scratch the user interface programs from the book. As programmers, we have more options than ever when it comes to developing a user interface, so the fact that SAS will let us create a text-only user interface design at no extra charge is not much more than a curiosity at this point — for most of us, anyway.

Meanwhile, it is no secret that the Internet has become more important. When I asked around, the recurring theme in the requests was output. Readers asked for more details on some subjects I barely touched on in previous editions, especially ODS, HTML, and XML. I will try to come up with short examples to show how easy it is to do the basic things in these areas. There were also requests specifically for more information on spreadsheet files. Apparently, passing data around in spreadsheet form has become as commonplace in the corporate workplace as printouts and handwritten documents were five years ago. I know it has been an increasing part of my own work.

Taking all the requests into account, this is the proposed (and still very tentative) table of contents for the 3rd edition of Professional SAS Programming Shortcuts (the mostly-new chapters in red):


  1. The Log
  2. Program Files
  3. Startup
  4. System Options
  5. Libraries
  6. Data Set Options
  7. Indexes
  8. Actions on SAS Data Sets
  9. Data Type and Length
  10. Text Data Files
  11. Data Fields
  12. Delimited Files
  13. Hierarchical Files
  14. Binary Files
  15. Value Formats
  16. Value Informats
  17. Picture Formats for Numbers
  18. Format Catalogs and Control Data Sets
  19. Time
  20. Informats and Formats for Time
  21. International Date Formats
  22. Picture Formats for Time
  23. Validation
  24. Strings
  25. Parsing
  26. Variable-Length Strings
  27. Foreign Data Types
  28. Codes
  29. Text Encryption
  30. Discrete Binary Encoding
  31. Bitfields
  32. Numeric Effects
  33. Missing Values
  34. Boolean Values
  35. Financial Calculations
  36. Time Conversions
  37. Time Arithmetic
  38. Extending the Observation Loop
  39. Loops
  40. Character Loops
  41. Subsetting and Sampling
  42. SQL
  43. Sorting
  44. Groups
  45. Incomplete Data
  46. Transposing
  47. Frequency Tables
  48. Descriptive Statistics
  49. Summary Statistics in Computations
  50. Type Conversion
  51. Combining Data
  52. Table Lookup
  53. Table Lookup From SAS Data Files
  54. Value Formats for Table Lookup
  55. Calendars
  56. Multiple Text Files
  57. Print Files
  58. Table Reports
  59. Summary Reports
  60. Data Step Views
  61. Macro Variables
  62. Macros
  63. Macro Programming
  64. Program Parameters
  65. Generating Program Statements
  66. Control Reports
  67. Cleanup
  68. Efficiency
  69. ODS
  70. ODS Objects
  71. ODS Destinations
  72. HTML
  73. ODS Style
  74. Pages and Printing
  75. XML
  76. The XML Engine
  77. Tagsets
  78. Internet Services
  79. Spreadsheets
  80. Word Processing and Email
  81. Text Processing
  82. Text Analysis
  83. Random Numbers
  84. Simulations
  85. Data Center Techniques
  86. Porting Files and Data
  87. Porting SAS Programs
  88. Classic Problems