frequently used character, numeric, and date functions
Character functions
ANYALNUM(str, startpos)
Return position of first occurrence of any alphabetic or numeric value after or at the start postion
ANYALPHA(str, startpos)
Return position of first occurrence of any alphabetic value after or at the start postion
ANYDIGIT(str, startpos)
Return position of first occurrence of any numeric value after or at the start postion
ANYSPACE(str, startpos)
Return position of first occurrence of any whitespace after or at the start postion
LEFT(str)
Move all leading white spaces to end of string to left align strings
TRIM(str)
Removes trailing blanks from a character expression, and returns one blank if the string is missing.
STRIP(str)
Returns a character string with all leading and trailing blanks removed.
UPCASE
Convert all alphabets to upper case
LOWCASE
Convert all alphabets to lower case
PROPCASE
Convert all alphabets to proper case
INDEX(string, substring)
Search a string for a substring, and returns the position of the first occurrence of the substring.
SUBSTR(string, startpos, len)
Returns a substring, allowing a result with a length of zero.
FIND(string, substring)
Return the position of first occurrence of a specific substring within a string.
COMPRESS(source <, characters> <, modifier(s)>)
Returns a string with specified characters removed from the original string.
TRANSLATE(string, replacement-str, match-str)
Replaces specific characters in a string. The characters in the replacement-str(target) shall be substituted for those in the match-str (source)
TRANWRD(string, match-str, replacement-str)
Replaces all occurrences of a replacement-str in a string.
LENGTH(string)
Returns the length of a non-blank character string, excluding trailing blanks, and returns 1 for a blank character string.
LENGTHC(string)
Returns the length of a character string, including trailing blanks.
LENGTHN(string)
Returns the length of a character string, excluding trailing blanks.
Numeric functions
INT(n)
Return integer portion of a number
LOG(n)
Return natural logarithm
MAX(n1, n2, n3)
Return largest nonmissing value
MIN(n1, n2, n3)
Return smallest nonmissing value
N(n1, n2, n3)
Return number of non-blank (nonmissing) numeric values
NMISS(n1, n2, n3)
Return number of blank (missing) numeric values
CMISS(n1, n2, n3)
Return number of blank (missing) character or numeric values
Date and time functions
DATEJUL(Julian-date)
Convert a julian date to a SAS date
DAY(date), MONTH(date), YEAR(date)
Return the day, month, and year of a SAS date
QTR(date), WEEKDAY(date)
Return the quarter, day of a week of a SAS date
TODAY()
Return current date of the SAS system
MDY(month, day, year)
Convert numeric values to SAS date
YRDIF(date1, date2)
Return the year difference between two dates
INTCK(interval_unit, date1, date2, "C")
Return difference in days/weeks/months/years of two dates
interval_unit can be second, minute, hour, day, week, month, quarter, and year
"C" option will count time interval as complete (no partial)
INTNX(interval_unit, start_date, interval_value)
Return the actual date after a specified time interval