A SAS function is a routine that returns a value resulting
from zero or more arguments. To invoke a function, write its name
and then the argument or arguments for which the function is to be
performed enclosed in parentheses.
Function Arguments
Normally, when there is more than one argument, they must be
separated by commas. FUNCTIONNAME (expression<,expression...>)
The functions can also be written in the form: FUNCTIONNAME (OF variablelist)
Examples of this form include:
FUNCTIONNAME (OF X1-X10)
FUNCTIONNAME (OF A B C D)
FUNCTIONNAME (OF A--Z)
Function Results
The resulting or target variable for a function is usually
character if the arguments are character and numeric if the
arguments are numeric. The PUT function is an exception as its
result is a character value regardless of the type of argument.
The default length is 8 for numeric and 200 for character target
variables .
Functions to which the default target variable lengths do not
apply are shown below:
Function Target Variable Type Target Variable Length
BYTE Character 1
COMPRESS character length of first argument
INPUT character width of informat
numeric 8
LEFT character length of argument
PUT character width of format
REVERSE character length of argument
RIGHT character length of argument
SCAN character 200
SUBSTR character length of first argument
TRANSLATE character length of first argument
TRIM character length of argument
UPCASE character length of argument
DIM(arrayname) returns the number of elements in a one-dimensional array or the number of elements in a specified dimension of a multidimensional array
DIM(arrayname<,boundn>)
returns the number of elements in a one-dimensional array or the number of elements in a specified dimension of a multidimensional array
HBOUNDn(arrayname)
returns the upper bound of an array
HBOUND(arrayname,boundn)
returns the upper bound of an array
LBOUNDn(arrayname)
returns the lower bound of an array
LBOUND(arrayname,boundn)
returns the lower bound of an array
LOGPDF | LOGPMF
logarithm of the probability density or mass function.
PDF | PMF
probability density or mass function.
prob = CDF('id', quantile <, parameter-list>);
dens = PDF('id', quantile <, parameter-list>);
mass = PMF('id', quantile <, parameter-list>);
logd = LOGPDF('id', quantile <, parameter-list>);
logm = LOGPMF('id', quantile <, parameter-list>);
These functions represent a new syntax to simplify the calling
mechanism for computing probabilities, densities, and logarithms
of densities. Note that PMF is an alias for PDF and that
LOGPMF is an alias for LOGPDF.
'id' identifies the distribution.
The id must be enclosed in single quotes; valid distributions are:
BERNOULLI, BETA, BINOMIAL, CAUCHY, CHISQUARED, EXPONENTIAL, F,
GAMMA, GEOMETRIC, HYPERGEOMETRIC, LAPLACE, LOGISTIC, LOGNORMAL,
NEGBINOMIAL, NORMAL | GAUSSIAN, PARETO, POISSON, T, UNIFORM,
WALD | IGAUSS, and WEIBULL.
Note that each distribution is minimally identified by its first
four characters, except for the T and F distributions.
quantile is a numeric random variable.
The quantile is a numeric random variable, and it represents the
value at which you want the distribution evaluated.
parameter-list is a list of shape, location, and scale parameters
The parameter-list identifies distribution-specific shape,
location, and scale parameters. Consult the documentation for
the parameters appropriate to each of the available
distributions. Invalid arguments are not allowed, and a
missing value will be returned.
POISSON((lambda,n)
Poisson probability distribution function
PROBBETA(x,a,b)
beta probability distribution function
PROBBNML(p,n,m)
binomial probability distribution function
PROBCHI(x,df < , nc > )
chi-squared probability distribution function
PROBF(x,ndf,ddf < , nc > )
F distribution function
PROBGAM(x,a)
gamma probability distribution function
PROBHYPR(N,K,n,x < ,r > )
hypergeometric probability distribution function
PROBMC
probabilities and critical values (quantiles) from various
distributions for multiple comparisons of the means of several
groups.
value= PROBMC(string,q,prob,df,nparms < ,parameters > );
The PROBMC function can compute probabilities or quantiles from
the one-sided or two-sided Dunnett, Range, and Maximum Modulus
distributions with finite and infinite degrees of freedom. It
also computes Williams test. Note that prob is the probability
that the random variable is less than q. Therefore, p-values
can be computed as 1-prob. See Technical Report P-229 for
detail.
string is a character string identifying the distribution.
It is one of the following: 'DUNNETT1', 'DUNNETT2', 'RANGE',
'MAXMOD,' or 'WILLIAMS'.
q is the quantile from the distribution. Only one of the parameters q and prob should be specified. The other should be set to missing.
prob is the left probability from the distribution. Only one of the parameters q and prob should be specified. The other should be set to missing.
df is the degrees of freedom. A missing value is interpreted as an infinite value.
nparms is the numbers of treatments. For DUNNETT1 and DUNNETT2, the control group is not counted.
parameters is the set of nparms parameters that must be specified to handle the unequal case. The meaning of parameters depends on the distribution. If parameters is not specified, equal parameters are assumed. This is usually the situation for a null hypothesis.
PROBNEGB(p,n,m)
negative binomial probability distribution function
PROBBNRM(x,y,r)
standardized bivariate normal distribution
PROBNORM(x)
standard normal probability distribution function
p= PROBBNRM(x,y,r);
p is the returned probability.
x is a numeric variable.
r is a numeric correlation with -1 < = r < = 1.
The PROBBNRM function returns the probability that an
observation (x,y) from a standardized bivariate normal
distribution with mean 0, variance 1, and a correlation p,
is less than or equal to (a,b), that is, x < = a and y < = b.
PROBT(x,df < ,nc > )
Student's t distribution function