When planning modifications to SAS datasets, examine the many SAS functions that are available. In addition to formulas which can be entered by a user, SAS has many built in functions that greatly reduce the need to enter commands. SAS functions are pre-written expressions that provide shortcuts for many calculations and manipulations of data. A function returns a value from an internal computation or performs a utility task on the variables entered into it. SAS provides a library of built-in functions for a variety of tasks. This chapter summarizes a few of the most commonly entered functions and perhaps a few that are not so well known that you may find helpful.
The syntax of a function is defined by a name SAS recognizes, followed by function arguments separated by commas and enclosed in parentheses. Functions are enter as part of SAS statements such as a variable name would be entered at a particular point.
Functions and their documentation can be found on line in a document called TS486 -- a short summary of formats, informats, and functions. It has not yet been updated for version 9 but is expected to be ready by the end of this year (2004). It is about 20 pages long and gives one-line descriptions of each item. With this layout, one may easily scan a group of entries such as date formats and quickly search for possible solutions to a problem. If one looks helpful, look it up in the on-line documentation for a more thorough description.
This chapter only serves to highlight some features of commonly applied SAS functions. Many more are listed and illustrated in the SAS manuals or at the local web-site:
You can access directly the help documentation for a function or a procedure by highlighting in the Enhanced Editor window the name of the function or procedure and then pressing the F1 key.
The behavior of functions is not always as you might expect, so it is wise to examine your results and test the output thoroughly.
Last updated: 06/22/2006