最全的SAS9.2函数列表一 SAS资源资讯列表
22 11月 10 最全的SAS9.2函数列表一
SAS提供了大量的内置函数,并且在数量和内容上不断的发展改进,从版本9.2开始还提供了自定义函数功能。使用合适的函数,将会使你的工作效率加倍。2008年我在SASor论坛上贴了一个SAS9.2新增函数的列表,具体见论坛帖子;2009年我曾经在技术博客上对SAS函数做了比较深入的讨论,对SAS函数从版本6到版本9.2进行了细致的综述,详见“SAS函数&CALL例程介绍与实例精选“,并在SAS爱好者上海聚会分享了这一内容,当时的PPT见“SAS函数和CALL 例程的发展”。
当时所关注的函数其实仅仅集中于SAS常规函数,尽管如此,SAS9.2 的常规函数已达到499个。庞大的函数库确实给SASor们带来了非常多的方便,但是仓库式的SAS builted in帮助太杂乱,常常让人有一种“不识庐山真面目,只缘身在此山中”的感觉。有时,需要的函数找不到,找到的函数又不合适。其实SAS很体贴地不断增加高效的函数来精简你的代码和提高编程速度,可惜很多函数,SASor们并不知晓,常常看到别人使用的时候,才惊叹“原来SAS已经提供了这样的函数,我编了半天小算法”,或者“白费这么大劲,编了个宏”等等。这里按类列出SAS9.2版本的函数,供大家参考。
按不同的使用环境,SAS一共有七大类函数:
一,常规函数 ;二,windows环境下函数;三,OpenVMS虚拟内存环境下函数;四,z/OS操作环境下函数,五,宏语言函数;六,多国语言函数,七,其他函数
第一类函数常规函数最常用,数量也最多,这里依次列出所有的常规函数。
Character 字符函数
ANYALNUM Function Searches a character string for an alphanumeric character, and returns the first position at which the character is found.
ANYALPHA Function Searches a character string for an alphabetic character, and returns the first position at which the character is found.
ANYCNTRL Function Searches a character string for a control character, and returns the first position at which that character is found.
ANYDIGIT Function Searches a character string for a digit, and returns the first position at which the digit is found.
ANYFIRST Function Searches a character string for a character that is valid as the first character in a SAS variable name under VALIDVARNAME=V7, and returns the first position at which that character is found.
ANYGRAPH Function Searches a character string for a graphical character, and returns the first position at which that character is found.
ANYLOWER Function Searches a character string for a lowercase letter, and returns the first position at which the letter is found.
ANYNAME Function Searches a character string for a character that is valid in a SAS variable name under VALIDVARNAME=V7, and returns the first position at which that character is found.
ANYPRINT Function Searches a character string for a printable character, and returns the first position at which that character is found.
ANYPUNCT Function Searches a character string for a punctuation character, and returns the first position at which that character is found.
ANYSPACE Function Searches a character string for a white-space character (blank, horizontal and vertical tab, carriage return, line feed, and form feed), and returns the first position at which that character is found.
ANYUPPER Function Searches a character string for an uppercase letter, and returns the first position at which the letter is found.
ANYXDIGIT Function Searches a character string for a hexadecimal character that represents a digit, and returns the first position at which that character is found.
BYTE Function Returns one character in the ASCII or the EBCDIC collating sequence.
CALL CATS Routine Removes leading and trailing blanks, and returns a concatenated character string.
CALL CATT Routine Removes trailing blanks, and returns a concatenated character string.
CALL CATX Routine Removes leading and trailing blanks, inserts delimiters, and returns a concatenated character string.
CALL COMPCOST Routine Sets the costs of operations for later use by the COMPGED function
CALL MISSING Routine Assigns missing values to the specified character or numeric variables.
CALL SCAN Routine Returns the position and length of the nth word from a character string.
CAT Function Does not remove leading or trailing blanks, and returns a concatenated character string.
CATQ Function Concatenates character or numeric values by using a delimiter to separate items and by adding quotation marks to strings that contain the delimiter.
CATS Function Removes leading and trailing blanks, and returns a concatenated character string.
CATT Function Removes trailing blanks, and returns a concatenated character string.
CATX Function Removes leading and trailing blanks, inserts delimiters, and returns a character string.
CHAR Function Returns a single character from a specified position in a character string.
CHOOSEC Function Returns a character value that represents the results of choosing from a list of arguments.
CHOOSEN Function Returns a numeric value that represents the results of choosing from a list of arguments.
COALESCEC Function Returns the first non-missing value from a list of character arguments.
COLLATE Function Returns a character string in ASCII or EBCDIC collating sequence.
COMPARE Function Returns the position of the leftmost character by which two strings differ, or returns 0 if there is no difference.
COMPBL Function Removes multiple blanks from a character string.
COMPGED Function Returns the generalized edit distance between two strings.
COMPLEV Function Returns the Levenshtein edit distance between two strings.
COMPRESS Function Returns a character string with specified characters removed from the original string.
COUNT Function Counts the number of times that a specified substring appears within a character string.
COUNTC Function Counts the number of characters in a string that appear or do not appear in a list of characters.
COUNTW Function Counts the number of words in a character string.
DEQUOTE Function Removes matching quotation marks from a character string that begins with a quotation mark, and deletes all characters to the right of the closing quotation mark.
FIND Function Searches for a specific substring of characters within a character string.
FINDC Function Searches a string for any character in a list of characters.
FINDW Function Returns the character position of a word in a string, or returns the number of the word in a string.
FIRST Function Returns the first character in a character string.
IFC Function Returns a character value based on whether an expression is true, false, or missing.
INDEX Function Searches a character expression for a string of characters, and returns the position of the string’s first character for the first occurrence of the string.
INDEXC Function Searches a character expression for any of the specified characters, and returns the position of that character.
INDEXW Function Searches a character expression for a string that is specified as a word, and returns the position of the first character in the word.
LEFT Function Left-aligns a character string.
LENGTH Function Returns the length of a non-blank character string, excluding trailing blanks, and returns 1 for a blank character string.
LENGTHC Function Returns the length of a character string, including trailing blanks.
LENGTHM Function Returns the amount of memory (in bytes) that is allocated for a character string.
LENGTHN Function Returns the length of a character string, excluding trailing blanks.
LOWCASE Function Converts all letters in an argument to lowercase.
MD5 Function Returns the result of the message digest of a specified string.
MISSING Function Returns a numeric result that indicates whether the argument contains a missing value.
NLITERAL Function Converts a character string that you specify to a SAS name literal.
NOTALNUM Function Searches a character string for a non-alphanumeric character, and returns the first position at which the character is found.
NOTALPHA Function Searches a character string for a nonalphabetic character, and returns the first position at which the character is found.
NOTCNTRL Function Searches a character string for a character that is not a control character, and returns the first position at which that character is found.
NOTDIGIT Function Searches a character string for any character that is not a digit, and returns the first position at which that character is found.
NOTFIRST Function Searches a character string for an invalid first character in a SAS variable name under VALIDVARNAME=V7, and returns the first position at which that character is found.
NOTGRAPH Function Searches a character string for a non-graphical character, and returns the first position at which that character is found.
NOTLOWER Function Searches a character string for a character that is not a lowercase letter, and returns the first position at which that character is found.
NOTNAME Function Searches a character string for an invalid character in a SAS variable name under VALIDVARNAME=V7, and returns the first position at which that character is found.
NOTPRINT Function Searches a character string for a nonprintable character, and returns the first position at which that character is found.
NOTPUNCT Function Searches a character string for a character that is not a punctuation character, and returns the first position at which that character is found.
NOTSPACE Function Searches a character string for a character that is not a white-space character (blank, horizontal and vertical tab, carriage return, line feed, and form feed), and returns the first position at which that character is found.
NOTUPPER Function Searches a character string for a character that is not an uppercase letter, and returns the first position at which that character is found.
NOTXDIGIT Function Searches a character string for a character that is not a hexadecimal character, and returns the first position at which that character is found.
NVALID Function Checks the validity of a character string for use as a SAS variable name.
PROPCASE Function Converts all words in an argument to proper case.
QUOTE Function Adds double quotation marks to a character value.
RANK Function Returns the position of a character in the ASCII or EBCDIC collating sequence.
REPEAT Function Returns a character value that consists of the first argument repeated n+1 times.
REVERSE Function Reverses a character string.
RIGHT Function Right aligns a character expression.
SCAN Function Returns the nth word from a character string.
SOUNDEX Function Encodes a string to facilitate searching.
SPEDIS Function Determines the likelihood of two words matching, expressed as the asymmetric spelling distance between the two words.
STRIP Function Returns a character string with all leading and trailing blanks removed.
SUBPAD Function Returns a substring that has a length you specify, using blank padding if necessary.
SUBSTR (left of =) Function Replaces character value contents.
SUBSTR (right of =) Function Extracts a substring from an argument.
SUBSTRN Function Returns a substring, allowing a result with a length of zero.
TRANSLATE Function Replaces specific characters in a character string.
TRANSTRN Function Replaces all occurrences of a substring found in a character string, allowing a zero-length replacement string.
TRANWRD Function Replaces or removes all occurrences of a substring in a character string.
TRIM Function Removes trailing blanks from a character string, and returns one blank if the string is missing.
TRIMN Function Removes trailing blanks from character expressions, and returns a string with a length of zero if the expression is missing.
UPCASE Function Converts all letters in an argument to uppercase.
VERIFY Function Returns the position of the first character in a string that is not in any of several other strings.