The post is about Functions in SAS Software. Functions in SAS software are predefined routines that perform specific computations or transformations on data. They can be categorized into several types based on their functionality.
Table of Contents
Introduction to Functions in SAS Software
SAS functions are predefined operations that perform specific computations on data, categorized by their purpose. Numeric functions handle mathematical calculations like rounding, summing, and logarithms. Character functions manipulate text data through substring extraction, case conversion, and concatenation. Date and time functions manage SAS date, time, and datetime values, enabling operations like extracting year/month/day or shifting dates by intervals.
In SAS, Statistical functions compute summary metrics such as mean, median, and standard deviation. Financial functions support business calculations like net present value and loan payments. Random number functions generate values from statistical distributions for simulations. Bitwise functions perform low-level binary operations. Array functions assist in managing array dimensions and bounds. Special functions include utilities for data type conversion and lagged value retrieval. Finally, file and I/O functions check file existence and manage input/output operations. Together, these functions streamline data processing, analysis, and reporting in SAS.
Here are the main types of functions in SAS Software:
Numeric Functions
Perform mathematical operations on numeric values. These functions are also called arithmetic functions.
Function | Short Description |
---|---|
SUM() | Sum of arguments |
MEAN() | Arithmetic mean |
MIN() / MAX() | Minimum/Maximum value |
ROUND() | Rounds a number |
INT() | Returns integer part of a number |
ABS() | Absolute value of the argument |
SQRT() | Square root |
LOG() / LOG10() | Returns the integer part of a number |
Random Number Functions in SAS
These functions generate random numbers.
Random Number Function | Short Description |
---|---|
RANUNI() | Generates random numbers from Uniform distribution |
RANNOR() | Generates random numbers from a Normal distribution |
RANBIN() | Generates random numbers from a Binomial distribution |
Financial Functions
The following are important and useful financial calculations.
Financial Functions | Short Description |
---|---|
IRR() | Internal rate of return |
NPV() | Returns Net Present Value |
PMT() | Loan payment calculation |
Character Functions in SAS
Manipulate and analyze text (string) data. These functions can also be classified as character-handling functions.
Character Functions | Short Description |
---|---|
SUBSTR() | Extracts a substring from an argument |
SCAN() | Extracts a specified word from a string |
TRIM() / STRIP() | Removes trailing/leading blanks from character expression |
UPCASE() / LOWCASE() | Converts to uppercase/lowercase |
CATX() | Concatenates strings with a delimiter |
INDEX() | Finds the position of a |
COMPRESS() | Removes specific characters from a string |
Statistical Functions
The following are some important functions for the computation of descriptive statistical measures.
Descriptive Functions | Short Description |
---|---|
MEAN(), MEDIAN(), MODE() | Returns measures of central tendencies, mean, median, and mode of the data |
STD() | Returns standard deviation |
VAR() | Returns the variance |
N() | Returns the count of non-missing values |
NMISS() | Returns the count of missing values |
Date and Time Functions in SAS
These functions handle SAS date, time, and datetime values.
Functions | Short Description |
---|---|
TODAY() / DATE() | Returns the current date |
MDY() | Creates a date from month, day, year |
YEAR() / MONTH() / DAY() | Extracts year/month/day |
INTCK() | Computes intervals between dates |
INTNX() | Increments a date by intervals |
DATEPART() | Extracts the date from datetime |
TIMEPART() | Extracts time from datetime |
Bitwise Functions
The following functions perform bit-level operations.
Functions | Short Description |
---|---|
BAND() | Bitwise AND |
BOR() | Bitwise OR |
BNOT() | Bitwise NOT |
Array Functions
The following functions work with arrays.
Functions | Short Description |
---|---|
DIM() | Returns the size of an array |
HBOUND() / LBOUND() | Returns upper/ lower bounds of an array |
Special Functions
Miscellaneous operations. These functions may be classified as conversion functions, too.
Functions | Short Description |
---|---|
INPUT() | Converts character to numeric/ date |
PUT() | Converts value to formatted text |
LAG() / DIF() | Access previous row values |
File and I/O Functions
These functions handle file operations.
Functions | Short Description |
---|---|
FILEEXIST() | Checks if a file exists |
FEXIST() | Checks if a fileref exists |
The SAS functions described above help us in data cleaning, transformation, and analysis in SAS programming/ Software.
First Year (Intermediate) Mathematics Quiz