SAS提供了大量的内置函数，并且在数量和内容上不断的发展改进，从版本9.2开始还提供了自定义函数功能。使用合适的函数，将会使你的工作效率加倍。

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. |

**日期和时间函数 Date and Time**

CALL IS8601_CONVERT Routine | Converts an ISO 8601 interval to datetime and duration values, or converts datetime and duration values to an ISO 8601 interval. |

DATDIF Function | Returns the number of days between two dates. |

DATE Function | Returns the current date as a SAS date value. |

DATEJUL Function | Converts a Julian date to a SAS date value. |

DATEPART Function | Extracts the date from a SAS datetime value. |

DATETIME Function | Returns the current date and time of day as a SAS datetime value. |

DAY Function | Returns the day of the month from a SAS date value. |

DHMS Function | Returns a SAS datetime value from date, hour, minute, and second values. |

HMS Function | Returns a SAS time value from hour, minute, and second values. |

HOLIDAY Function | Returns a SAS date value of a specified holiday for a specified year. |

HOUR Function | Returns the hour from a SAS time or datetime value. |

INTCINDEX Function | Returns the cycle index when a date, time, or datetime interval and value are specified. |

INTCK Function | Returns the count of the number of interval boundaries between two dates, two times, or two datetime values. |

INTCYCLE Function | Returns the date, time, or datetime interval at the next higher seasonal cycle when a date, time, or datetime interval is specified. |

INTFIT Function | Returns a time interval that is aligned between two dates. |

INTFMT Function | Returns a recommended SAS format when a date, time, or datetime interval is specified. |

INTGET Function | Returns a time interval based on three date or datetime values. |

INTINDEX Function | Returns the seasonal index when a date, time, or datetime interval and value are specified. |

INTNX Function | Increments a date, time, or datetime value by a given time interval, and returns a date, time, or datetime value. |

INTSEAS Function | Returns the length of the seasonal cycle when a date, time, or datetime interval is specified. |

INTSHIFT Function | Returns the shift interval that corresponds to the base interval. |

INTTEST Function | Returns 1 if a time interval is valid, and returns 0 if a time interval is invalid. |

JULDATE Function | Returns the Julian date from a SAS date value. |

JULDATE7 Function | Returns a seven-digit Julian date from a SAS date value. |

MDY Function | Returns a SAS date value from month, day, and year values. |

MINUTE Function | Returns the minute from a SAS time or datetime value. |

MONTH Function | Returns the month from a SAS date value. |

NWKDOM Function | Returns the date for the nth occurrence of a weekday for the specified month and year. |

QTR Function | Returns the quarter of the year from a SAS date value. |

SECOND Function | Returns the second from a SAS time or datetime value. |

TIME Function | Returns the current time of day as a numeric SAS time value. |

TIMEPART Function | Extracts a time value from a SAS datetime value. |

TODAY Function | Returns the current date as a numeric SAS date value. |

WEEK Function | Returns the week-number value. |

WEEKDAY Function | From a SAS date value, returns an integer that corresponds to the day of the week. |

YEAR Function | Returns the year from a SAS date value. |

YRDIF Function | Returns the difference in years between two dates. |

YYQ Function | Returns a SAS date value from year and quarter year values. |

**描述统计函数 Descriptive Statistics**

CMISS Function | Counts the number of missing arguments. |

CSS Function | Returns the corrected sum of squares. |

CV Function | Returns the coefficient of variation. |

EUCLID Function | Returns the Euclidean norm of the non-missing arguments. |

GEOMEAN Function | Returns the geometric mean. |

GEOMEANZ Function | Returns the geometric mean, using zero fuzzing. |

HARMEAN Function | Returns the harmonic mean. |

HARMEANZ Function | Returns the harmonic mean, using zero fuzzing. |

IQR Function | Returns the interquartile range. |

KURTOSIS Function | Returns the kurtosis. |

LARGEST Function | Returns the kth largest non-missing value. |

LPNORM Function | Returns the Lp norm of the second argument and subsequent non-missing arguments. |

MAD Function | Returns the median absolute deviation from the median. |

MAX Function | Returns the largest value. |

MEAN Function | Returns the arithmetic mean (average). |

MEDIAN Function | Returns the median value. |

MIN Function | Returns the smallest value. |

MISSING Function | Returns a numeric result that indicates whether the argument contains a missing value. |

N Function | Returns the number of non-missing numeric values. |

NMISS Function | Returns the number of missing numeric values. |

ORDINAL Function | Returns the kth smallest of the missing and nonmissing values. |

PCTL Function | Returns the percentile that corresponds to the percentage. |

RANGE Function | Returns the range of the nonmissing values. |

RMS Function | Returns the root mean square of the nonmissing arguments. |

SKEWNESS Function | Returns the skewness of the nonmissing arguments. |

SMALLEST Function | Returns the kth smallest nonmissing value. |

STD Function | Returns the standard deviation of the nonmissing arguments. |

STDERR Function | Returns the standard error of the mean of the nonmissing arguments. |

SUM Function | Returns the sum of the nonmissing arguments. |

SUMABS Function | Returns the sum of the absolute values of the non-missing arguments. |

USS Function | Returns the uncorrected sum of squares of the nonmissing arguments. |

VAR Function | Returns the variance of the nonmissing arguments. |

**数学函数 Mathematical**

ABS Function | Returns the absolute value. |

AIRY Function | Returns the value of the Airy function. |

BETA Function | Returns the value of the beta function. |

CALL LOGISTIC Routine | Applies the logistic function to each argument. |

CALL SOFTMAX Routine | Returns the softmax value. |

CALL STDIZE Routine | Standardizes the values of one or more variables. |

CALL TANH Routine | Returns the hyperbolic tangent. |

CNONCT Function | Returns the noncentrality parameter from a chi-square distribution. |

COALESCE Function | Returns the first non-missing value from a list of numeric arguments. |

CONSTANT Function | Computes machine and mathematical constants. |

DAIRY Function | Returns the derivative of the AIRY function. |

DEVIANCE Function | Returns the deviance based on a probability distribution. |

DIGAMMA Function | Returns the value of the digamma function. |

ERF Function | Returns the value of the (normal) error function. |

ERFC Function | Returns the value of the complementary (normal) error function. |

EXP Function | Returns the value of the exponential function. |

FACT Function | Computes a factorial. |

FNONCT Function | Returns the value of the noncentrality parameter of an F distribution. |

GAMMA Function | Returns the value of the gamma function. |

GCD Function | Returns the greatest common divisor for one or more integers. |

IBESSEL Function | Returns the value of the modified Bessel function. |

JBESSEL Function | Returns the value of the Bessel function. |

LCM Function | Returns the least common multiple. |

LGAMMA Function | Returns the natural logarithm of the Gamma function. |

LOG Function | Returns the natural (base e) logarithm. |

LOG1PX Function | Returns the log of 1 plus the argument. |

LOG10 Function | Returns the logarithm to the base 10. |

LOG2 Function | Returns the logarithm to the base 2. |

LOGBETA Function | Returns the logarithm of the beta function. |

MOD Function | Returns the remainder from the division of the first argument by the second argument, fuzzed to avoid most unexpected floating-point results. |

MODZ Function | Returns the remainder from the division of the first argument by the second argument, using zero fuzzing. |

MSPLINT Function | Returns the ordinate of a monotonicity-preserving interpolating spline. |

SIGN Function | Returns the sign of a value. |

SQRT Function | Returns the square root of a value. |

TNONCT Function | Returns the value of the noncentrality parameter from the Student’s t distribution. |

TRIGAMMA Function | Returns the value of the trigamma function. |

**分布密度函数、分布函数 Probability**

CDF Function | Returns a value from a cumulative probability distribution. |

LOGCDF Function | Returns the logarithm of a left cumulative distribution function. |

LOGPDF Function | Returns the logarithm of a probability density (mass) function. |

LOGSDF Function | Returns the logarithm of a survival function. |

PDF Function | Returns a value from a probability density (mass) distribution. |

POISSON Function | Returns the probability from a Poisson distribution. |

PROBBETA Function | Returns the probability from a beta distribution. |

PROBBNML Function | Returns the probability from a binomial distribution. |

PROBBNRM Function | Returns a probability from a bivariate normal distribution. |

PROBCHI Function | Returns the probability from a chi-square distribution. |

PROBF Function | Returns the probability from an F distribution. |

PROBGAM Function | Returns the probability from a gamma distribution. |

PROBHYPR Function | Returns the probability from a hypergeometric distribution. |

PROBMC Function | Returns a probability or a quantile from various distributions for multiple comparisons of means. |

PROBNEGB Function | Returns the probability from a negative binomial distribution. |

PROBNORM Function | Returns the probability from the standard normal distribution. |

PROBT Function | Returns the probability from a t distribution. |

SDF Function | Returns a survival function. |

**二进制逻辑操作符 Bitwise Logical Operations**

BAND Function | Returns the bitwise logical AND of two arguments. |

BLSHIFT Function | Returns the bitwise logical left shift of two arguments. |

BNOT Function | Returns the bitwise logical NOT of an argument. |

BOR Function | Returns the bitwise logical OR of two arguments. |

BRSHIFT Function | Returns the bitwise logical right shift of two arguments. |

BXOR Function | Returns the bitwise logical EXCLUSIVE OR of two arguments. |

**数组函数 Array**

DIM Function | Returns the number of elements in an array. |

HBOUND Function | Returns the upper bound of an array. |

LBOUND Function | Returns the lower bound of an array. |

**字符串配对函数 Character String Matching**

CALL PRXCHANGE Routine | Performs a pattern-matching replacement. |

CALL PRXDEBUG Routine | Enables Perl regular expressions in a DATA step to send debugging output to the SAS log. |

CALL PRXFREE Routine | Frees memory that was allocated for a Perl regular expression. |

CALL PRXNEXT Routine | Returns the position and length of a substring that matches a pattern, and iterates over multiple matches within one string. |

CALL PRXPOSN Routine | Returns the start position and length for a capture buffer. |

CALL PRXSUBSTR Routine | Returns the position and length of a substring that matches a pattern. |

PRXCHANGE Function | Performs a pattern-matching replacement. |

PRXMATCH Function | Searches for a pattern match and returns the position at which the pattern is found. |

PRXPAREN Function | Returns the last bracket match for which there is a match in a pattern. |

PRXPARSE Function | Compiles a Perl regular expression (PRX) that can be used for pattern matching of a character value. |

PRXPOSN Function | Returns a character string that contains the value for a capture buffer. |

**组合函数 Combinatorial**

ALLCOMB Function | Generates all combinations of the values of n variables taken k at a time in a minimal change order. |

ALLPERM Function | Generates all permutations of the values of several variables in a minimal change order. |

CALL ALLCOMB Routine | Generates all combinations of the values of n variables taken k at a time in a minimal change order. |

CALL ALLCOMBI Routine | Generates all combinations of the indices of n objects taken k at a time in a minimal change order. |

CALL ALLPERM Routine | Generates all permutations of the values of several variables in a minimal change order. |

CALL GRAYCODE Routine | Generates all subsets of n items in a minimal change order. |

CALL LEXCOMB Routine | Generates all distinct combinations of the non-missing values of n variables taken k at a time in lexicographic order. |

CALL LEXCOMBI Routine | Generates all combinations of the indices of n objects taken k at a time in lexicographic order. |

CALL LEXPERK Routine | Generates all distinct permutations of the non-missing values of n variables taken k at a time in lexicographic order. |

CALL LEXPERM Routine | Generates all distinct permutations of the non-missing values of several variables in lexicographic order. |

CALL RANPERK Routine | Randomly permutes the values of the arguments, and returns a permutation of k out of n values. |

CALL RANPERM Routine | Randomly permutes the values of the arguments. |

COMB Function | Computes the number of combinations of n elements taken r at a time. |

GRAYCODE Function | Generates all subsets of n items in a minimal change order. |

LCOMB Function | Computes the logarithm of the COMB function; that is, the logarithm of the number of combinations of n objects taken r at a time. |

LEXCOMB Function | Generates all distinct combinations of the non-missing values of n variables taken k at a time in lexicographic order. |

LEXCOMBI Function | Generates all combinations of the indices of n objects taken k at a time in lexicographic order. |

LEXPERK Function | Generates all distinct permutations of the non-missing values of n variables taken k at a time in lexicographic order. |

LEXPERM Function | Generates all distinct permutations of the non-missing values of several variables in lexicographic order. |

LFACT Function | Computes the logarithm of the FACT (factorial) function. |

LPERM Function | Computes the logarithm of the PERM function; that is, the logarithm of the number of permutations of n objects, with the option of including r number of elements. |

PERM Function | Computes the number of permutations of n items that are taken r at a time. |

**双曲线函数 Hyperbolic**

ARCOSH Function | Returns the inverse hyperbolic cosine. |

ARSINH Function | Returns the inverse hyperbolic sine. |

ARTANH Function | Returns the inverse hyperbolic tangent. |

COSH Function | Returns the hyperbolic cosine. |

SINH Function | Returns the hyperbolic sine. |

TANH Function | Returns the hyperbolic tangent. |

**宏函数 Macro**

CALL EXECUTE Routine | Resolves the argument, and issues the resolved value for execution at the next step boundary. |

CALL SYMPUT Routine | Assigns DATA step information to a macro variable. |

CALL SYMPUTX Routine | Assigns a value to a macro variable, and removes both leading and trailing blanks. |

RESOLVE Function | Returns the resolved value of the argument after it has been processed by the macro facility. |

SYMEXIST Function | Returns an indication of the existence of a macro variable. |

SYMGET Function | Returns the value of a macro variable during DATA step execution. |

SYMGLOBL Function | Returns an indication of whether a macro variable is in global scope to the DATA step during DATA step execution. |

SYMLOCAL Function | Returns an indication of whether a macro variable is in local scope to the DATA step during DATA step execution. |

**分位数函数 Quantile**

BETAINV Function | Returns a quantile from the beta distribution. |

CINV Function | Returns a quantile from the chi-square distribution. |

FINV Function | Returns a quantile from the F distribution. |

GAMINV Function | Returns a quantile from the gamma distribution. |

PROBIT Function | Returns a quantile from the standard normal distribution. |

QUANTILE Function | Returns the quantile from a distribution that you specify. |

TINV Function | Returns a quantile from the t distribution. |

**搜索函数 Search**

WHICHC Function | Searches for a character value that is equal to the first argument, and returns the index of the first matching value. |

WHICHN Function | Searches for a numeric value that is equal to the first argument, and returns the index of the first matching value. |

**排序函数Sort**

CALL SORTC Routine | Sorts the values of character arguments. |

CALL SORTN Routine | Sorts the values of numeric arguments. |

**外部例程 External Routines**

CALL MODULE Routine | Calls an external routine without any return code. |

MODULEC Function | Calls an external routine and returns a character value. |

MODULEN Function | Calls an external routine and returns a numeric value. |

**三角函数Trigonometric**

ARCOS Function | Returns the arccosine. |

ARSIN Function | Returns the arcsine. |

ATAN Function | Returns the arc tangent. |

ATAN2 Function | Returns the arc tangent of the ratio of two numeric variables. |

COS Function | Returns the cosine. |

SIN Function | Returns the sine. |

TAN Function | Returns the tangent. |

**截断函数 Truncation**

CEIL Function | Returns the smallest integer that is greater than or equal to the argument, fuzzed to avoid unexpected floating-point results. |

CEILZ Function | Returns the smallest integer that is greater than or equal to the argument, using zero fuzzing. |

FLOOR Function | Returns the largest integer that is less than or equal to the argument, fuzzed to avoid unexpected floating-point results. |

FLOORZ Function | Returns the largest integer that is less than or equal to the argument, using zero fuzzing. |

FUZZ Function | Returns the nearest integer if the argument is within 1E-12 of that integer. |

INT Function | Returns the integer value, fuzzed to avoid unexpected floating-point results. |

INTZ Function | Returns the integer portion of the argument, using zero fuzzing. |

ROUND Function | Rounds the first argument to the nearest multiple of the second argument, or to the nearest integer when the second argument is omitted. |

ROUNDE Function | Rounds the first argument to the nearest multiple of the second argument, and returns an even multiple when the first argument is halfway between the two nearest multiples. |

ROUNDZ Function | Rounds the first argument to the nearest multiple of the second argument, using zero fuzzing. |

TRUNC Function | Truncates a numeric value to a specified number of bytes. |

**变量控制函数Variable Control**

CALL LABEL Routine | Assigns a variable label to a specified character variable. |

CALL SET Routine | Links SAS data set variables to DATA step or macro variables that have the same name and data type. |

CALL VNAME Routine | Assigns a variable name as the value of a specified variable. |

**算术函数 Arithmetic**

DIVIDE | Returns the result of a division that handles special missing values for ODS output. |

**返回数值函数 Numeric**

IFN Function | Returns a numeric value based on whether an expression is true, false, or missing. |

**网络工具函数Web Tools**

HTMLDECODE Function | Decodes a string that contains HTML numeric character references or HTML character entity references, and returns the decoded string. |

HTMLENCODE Function | Encodes characters using HTML character entity references, and returns the encoded string. |

URLDECODE Function | Returns a string that was decoded using the URL escape syntax. |

URLENCODE Function | Returns a string that was encoded using the URL escape syntax. |

**外部文件函数 External Files**

DCLOSE Function | Closes a directory that was opened by the DOPEN function. |

DCREATE Function | Returns the complete pathname of a new, external directory. |

DINFO Function | Returns information about a directory. |

DNUM Function | Returns the number of members in a directory. |

DOPEN Function | Opens a directory, and returns a directory identifier value. |

DOPTNAME Function | Returns directory attribute information. |

DOPTNUM Function | Returns the number of information items that are available for a directory. |

DREAD Function | Returns the name of a directory member. |

DROPNOTE Function | Deletes a note marker from a SAS data set or an external file. |

FAPPEND Function | Appends the current record to the end of an external file. |

FCLOSE Function | Closes an external file, directory, or directory member. |

FCOL Function | Returns the current column position in the File Data Buffer (FDB). |

FDELETE Function | Deletes an external file or an empty directory. |

FEXIST Function | Verifies the existence of an external file that is associated with a fileref. |

FGET Function | Copies data from the File Data Buffer (FDB) into a variable. |

FILEEXIST Function | Verifies the existence of an external file by its physical name. |

FILENAME Function | Assigns or deassigns a fileref to an external file, directory, or output device. |

FILEREF Function | Verifies whether a fileref has been assigned for the current SAS session. |

FINFO Function | Returns the value of a file information item. |

FNOTE Function | Identifies the last record that was read, and returns a value that the FPOINT function can use. |

FOPEN Function | Opens an external file and returns a file identifier value. |

FOPTNAME Function | Returns the name of an item of information about a file. |

FOPTNUM Function | Returns the number of information items that are available for an external file. |

FPOINT Function | Positions the read pointer on the next record to be read. |

FPOS Function | Sets the position of the column pointer in the File Data Buffer (FDB). |

FPUT Function | Moves data to the File Data Buffer (FDB) of an external file, starting at the FDB’s current column position. |

FREAD Function | Reads a record from an external file into the File Data Buffer (FDB). |

FREWIND Function | Positions the file pointer to the start of the file. |

FRLEN Function | Returns the size of the last record that was read, or, if the file is opened for output, returns the current record size. |

FSEP Function | Sets the token delimiters for the FGET function. |

FWRITE Function | Writes a record to an external file. |

MOPEN Function | Opens a file by directory ID and member name, and returns either the file identifier or a 0. |

PATHNAME Function | Returns the physical name of an external file or a SAS library, or returns a blank. |

RENAME Function | Renames a member of a SAS library, an entry in a SAS catalog, an external file, or a directory. |

SYSMSG Function | Returns error or warning message text from processing the last data set or external file function. |

SYSRC Function | Returns a system error number. |

**金融函数Financial**

BLACKCLPRC Function | Calculates call prices for European options on futures, based on the Black model. |

BLACKPTPRC Function | Calculates put prices for European options on futures, based on the Black model. |

BLKSHCLPRC Function | Calculates call prices for European options on stocks, based on the Black-Scholes model. |

BLKSHPTPRC Function | Calculates put prices for European options on stocks, based on the Black-Scholes model. |

COMPOUND Function | Returns compound interest parameters. |

CONVX Function | Returns the convexity for an enumerated cash flow. |

CONVXP Function | Returns the convexity for a periodic cash flow stream, such as a bond. |

DACCDB Function | Returns the accumulated declining balance depreciation. |

DACCDBSL Function | Returns the accumulated declining balance with conversion to a straight-line depreciation. |

DACCSL Function | Returns the accumulated straight-line depreciation. |

DACCSYD Function | Returns the accumulated sum-of-years-digits depreciation. |

DACCTAB Function | Returns the accumulated depreciation from specified tables. |

DEPDB Function | Returns the declining balance depreciation. |

DEPDBSL Function | Returns the declining balance with conversion to a straight-line depreciation. |

DEPSL Function | Returns the straight-line depreciation. |

DEPSYD Function | Returns the sum-of-years-digits depreciation. |

DEPTAB Function | Returns the depreciation from specified tables. |

DUR Function | Returns the modified duration for an enumerated cash flow. |

DURP Function | Returns the modified duration for a periodic cash flow stream, such as a bond. |

FINANCE Function | Computes financial calculations such as depreciation, maturation, accrued interest, net present value, periodic savings, and internal rates of return. |

GARKHCLPRC Function | Calculates call prices for European options on stocks, based on the Garman-Kohlhagen model. |

GARKHPTPRC Function | Calculates put prices for European options on stocks, based on the Garman-Kohlhagen model. |

INTRR Function | Returns the internal rate of return as a fraction. |

IRR Function | Returns the internal rate of return as a percentage. |

MARGRCLPRC Function | Calculates call prices for European options on stocks, based on the Margrabe model. |

MARGRPTPRC Function | Calculates put prices for European options on stocks, based on the Margrabe model. |

MORT Function | Returns amortization parameters. |

NETPV Function | Returns the net present value as a fraction. |

NPV Function | Returns the net present value with the rate expressed as a percentage. |

PVP Function | Returns the present value for a periodic cash flow stream (such as a bond), with repayment of principal at maturity. |

SAVING Function | Returns the future value of a periodic saving. |

YIELDP Function | Returns the yield-to-maturity for a periodic cash flow stream, such as a bond. |

**产生随机数函数 Random Number**

CALL RANBIN Routine | Returns a random variate from a binomial distribution. |

CALL RANCAU Routine | Returns a random variate from a Cauchy distribution. |

CALL RANEXP Routine | Returns a random variate from an exponential distribution. |

CALL RANGAM Routine | Returns a random variate from a gamma distribution. |

CALL RANNOR Routine | Returns a random variate from a normal distribution. |

CALL RANPOI Routine | Returns a random variate from a Poisson distribution. |

CALL RANTBL Routine | Returns a random variate from a tabled probability distribution. |

CALL RANTRI Routine | Returns a random variate from a triangular distribution. |

CALL RANUNI Routine | Returns a random variate from a uniform distribution. |

CALL STREAMINIT Routine | Specifies a seed value to use for subsequent random number generation by the RAND function. |

NORMAL Function | Returns a random variate from a normal, or Gaussian, distribution. |

RANBIN Function | Returns a random variate from a binomial distribution. |

RANCAU Function | Returns a random variate from a Cauchy distribution. |

RAND Function | Generates random numbers from a distribution that you specify. |

RANEXP Function | Returns a random variate from an exponential distribution. |

RANGAM Function | Returns a random variate from a gamma distribution. |

RANNOR Function | Returns a random variate from a normal distribution. |

RANPOI Function | Returns a random variate from a Poisson distribution. |

RANTBL Function | Returns a random variate from a tabled probability distribution. |

RANTRI Function | Returns a random variate from a triangular distribution. |

RANUNI Function | Returns a random variate from a uniform distribution. |

UNIFORM Function | Returns a random variate from a uniform distribution. |

**SAS文件IO函数 SAS File I/O**

ATTRC Function | Returns the value of a character attribute for a SAS data set. | |

ATTRN Function | Returns the value of a numeric attribute for a SAS data set. | |

CEXIST Function | Verifies the existence of a SAS catalog or SAS catalog entry. | |

CLOSE Function | Closes a SAS data set. | |

CUROBS Function | Returns the observation number of the current observation. | |

DROPNOTE Function | Deletes a note marker from a SAS data set or an external file. | |

DSNAME Function | Returns the SAS data set name that is associated with a data set identifier. | |

ENVLEN Function | Returns the length of an environment variable. | |

EXIST Function | Verifies the existence of a SAS library member. | |

FETCH Function | Reads the next non-deleted observation from a SAS data set into the Data Set Data Vector (DDV). | |

FETCHOBS Function | Reads a specified observation from a SAS data set into the Data Set Data Vector (DDV). | |

GETVARC Function | Returns the value of a SAS data set character variable. | |

GETVARN Function | Returns the value of a SAS data set numeric variable. | |

IORCMSG Function | Returns a formatted error message for width=”20%”>LIBNAME Function | Assigns or deassigns a libref for a SAS library. |

LIBREF Function | Verifies that a libref has been assigned. | |

NOTE Function | Returns an observation ID for the current observation of a SAS data set. | |

OPEN Function | Opens a SAS data set. | |

PATHNAME Function | Returns the physical name of an external file or a SAS library, or returns a blank. | |

POINT Function | Locates an observation that is identified by the NOTE function. | |

RENAME Function | Renames a member of a SAS library, an entry in a SAS catalog, an external file, or a directory. | |

REWIND Function | Positions the data set pointer at the beginning of a SAS data set. | |

SYSMSG Function | Returns error or warning message text from processing the last data set or external file function. | |

SYSRC Function | Returns a system error number. | |

VARFMT Function | Returns the format that is assigned to a SAS data set variable. | |

VARINFMT Function | Returns the informat that is assigned to a SAS data set variable. | |

VARLABEL Function | Returns the label that is assigned to a SAS data set variable. | |

VARLEN Function | Returns the length of a SAS data set variable. | |

VARNAME Function | Returns the name of a SAS data set variable. | |

VARNUM Function | Returns the number of a variable’s position in a SAS data set. | |

VARTYPE Function | Returns the data type of a SAS data set variable. |

**特殊函数 Special**

ADDR Function | Returns the memory address of a variable on a 32-bit platform. |

ADDRLONG Function | Returns the memory address of a variable on 32-bit and 64-bit platforms. |

CALL POKE Routine | Writes a value directly into memory on a 32-bit platform. |

CALL POKELONG Routine | Writes a value directly into memory on 32-bit and 64-bit platforms. |

CALL SLEEP Routine | For a specified period of time, suspends the execution of a program that invokes this CALL routine. |

CALL SYSTEM Routine | Submits an operating environment command for execution. |

DIF Function | Returns differences between an argument and its nth lag. |

GETOPTION Function | Returns the value of a SAS system or graphics option. |

INPUT Function | Returns the value that is produced when SAS converts an expression using the specified informat. |

INPUTC Function | Enables you to specify a character informat at run time. |

INPUTN Function | Enables you to specify a numeric informat at run time. |

LAG Function | Returns values from a queue. |

PEEK Function | Stores the contents of a memory address in a numeric variable on a 32-bit platform. |

PEEKC Function | Stores the contents of a memory address in a character variable on a 32-bit platform. |

PEEKCLONG Function | Stores the contents of a memory address in a character variable on 32-bit and 64-bit platforms. |

PEEKLONG Function | Stores the contents of a memory address in a numeric variable on 32-bit and 64-bit platforms. |

PTRLONGADD Function | Returns the pointer address as a character variable on 32-bit and 64-bit platforms. |

PUT Function | Returns a value using a specified format. |

PUTC Function | Enables you to specify a character format at run time. |

PUTN Function | Enables you to specify a numeric format at run time. |

SLEEP Function | For a specified period of time, suspends the execution of a program that invokes this function. |

SYSGET Function | Returns the value of the specified operating environment variable. |

SYSPARM Function | Returns the system parameter string. |

SYSPROCESSID Function | Returns the process ID of the current process. |

SYSPROCESSNAME Function | Returns the process name that is associated with a given process ID, or returns the name of the current process. |

SYSPROD Function | Determines whether a product is licensed. |

SYSTEM Function | Issues an operating environment command during a SAS session, and returns the system return code. |

UUIDGEN Function | Returns the short or binary form of a Universal Unique Identifier (UUID). |

**变量信息函数 Variable Information**

CALL VNEXT Routine | Returns the name, type, and length of a variable that is used in a DATA step. |

VARRAY Function | Returns a value that indicates whether the specified name is an array. |

VARRAYX Function | Returns a value that indicates whether the value of the specified argument is an array. |

VFORMAT Function | Returns the format that is associated with the specified variable. |

VFORMATD Function | Returns the decimal value of the format that is associated with the specified variable. |

VFORMATDX Function | Returns the decimal value of the format that is associated with the value of the specified argument. |

VFORMATN Function | Returns the format name that is associated with the specified variable. |

VFORMATNX Function | Returns the format name that is associated with the value of the specified argument. |

VFORMATW Function | Returns the format width that is associated with the specified variable. |

VFORMATWX Function | Returns the format width that is associated with the value of the specified argument. |

VFORMATX Function | Returns the format that is associated with the value of the specified argument. |

VINARRAY Function | Returns a value that indicates whether the specified variable is a member of an array. |

VINARRAYX Function | Returns a value that indicates whether the value of the specified argument is a member of an array. |

VINFORMAT Function | Returns the informat that is associated with the specified variable. |

VINFORMATD Function | Returns the decimal value of the informat that is associated with the specified variable. |

VINFORMATDX Function | Returns the decimal value of the informat that is associated with the value of the specified variable. |

VINFORMATN Function | Returns the informat name that is associated with the specified variable. |

VINFORMATNX Function | Returns the informat name that is associated with the value of the specified argument. |

VINFORMATW Function | Returns the informat width that is associated with the specified variable. |

VINFORMATWX Function | Returns the informat width that is associated with the value of the specified argument. |

VINFORMATX Function | Returns the informat that is associated with the value of the specified argument. |

VLABEL Function | Returns the label that is associated with the specified variable. |

VLABELX Function | Returns the label that is associated with the value of the specified argument. |

VLENGTH Function | Returns the compile-time (allocated) size of the specified variable. |

VLENGTHX Function | Returns the compile-time (allocated) size for the variable that has a name that is the same as the value of the argument. |

VNAME Function | Returns the name of the specified variable. |

VNAMEX Function | Validates the value of the specified argument as a variable name. |

VTYPE Function | Returns the type (character or numeric) of the specified variable. |

VTYPEX Function | Returns the type (character or numeric) for the value of the specified argument. |

VVALUE Function | Returns the formatted value that is associated with the variable that you specify. |

VVALUEX Function | Returns the formatted value that is associated with the argument that you specify. |

**美国人专用函数 与地理位置有关的一些函数 美国人对美国人真好**

函数名 | 作用 | |

Distance距离函数 | GEODIST Function | Returns the geodetic distance between two latitude and longitude coordinates. |

ZIPCITYDISTANCE Function | Returns the geodetic distance between two zip code locations. | |

State and Zip Code州和邮政编码 | FIPNAME Function | Converts two-digit FIPS codes to uppercase state names. |

FIPNAMEL Function | Converts two-digit FIPS codes to mixed case state names. | |

FIPSTATE Function | Converts two-digit FIPS codes to two-character state postal codes. | |

STFIPS Function | Converts state postal codes to FIPS state codes. | |

STNAME Function | Converts state postal codes to uppercase state names. | |

STNAMEL Function | Converts state postal codes to mixed case state names. | |

ZIPCITY Function | Returns a city name and the two-character postal code that corresponds to a zip code. | |

ZIPCITYDISTANCE Function | Returns the geodetic distance between two zip code locations. | |

ZIPFIPS Function | Converts zip codes to two-digit FIPS codes. | |

ZIPNAME Function | Converts zip codes to uppercase state names. | |

ZIPNAMEL Function | Converts zip codes to mixed case state names. | |

ZIPSTATE Function | Converts zip codes to two-character state postal codes. |

注：数据分析网遵循行业规范，任何转载的稿件都会明确标注作者和来源，若标注有误或遗漏，请联系主编邮箱：afenxi@afenxi.com