Title: Biostat Lab Section ProbabilityQuantile Functions
1Biostat Lab Section Probability/Quantile
Functions
2SAS Functions
- A SAS function performs a computation or system
manipulation on arguments and returns a value. - One can use SAS functions in
- DATA step programming statements,
- a WHERE expression,
- macro language statements,
- PROC REPORT, and
- Structured Query Language (SQL).
3SAS CALL Routines
- A CALL routine alters variable values or performs
other system functions. CALL routines are similar
to functions, but differ from functions in that
you cannot use them in assignment statements. - All SAS CALL routines are invoked with CALL
statements that is, the name of the routine must
appear after the keyword CALL on the CALL
statement.
4Using SAS Functions Restrictions on Function
Arguments
- If the value of an argument is invalid, SAS
prints an error message and sets the result to a
missing value. - Some functions require that their arguments be
restricted within a certain range. For example,
the argument of the LOG function must be greater
than 0.
5Using SAS Functions Restrictions on Function
Arguments
- Most functions do not permit missing values as
arguments. Exceptions include some of the
descriptive statistics functions and financial
functions. - For some probability functions, combinations of
extreme values can cause convergence problems.
6Syntax of Functions (1)
- function-name (argument-1lt. . .,argument-ngt)
- where
- function-name names the function.
- argument can be a variable name, constant, or
any SAS expression, including another function.
The number and kind of arguments allowed are
described with individual functions. Multiple
arguments are separated by a comma. - xmax(cash,credit)
7Syntax of Functions (2)
- function-name (OF variable-list)
- where
- (OF variable-list) can be any form of a SAS
variable list, including individual variable
names. If more than one variable list appears,
separate them with a space. - asum(of x y z)
8Syntax of Functions (3)
- function-name (OF array-name)
- where
- (OF array-name)names a currently defined
array. Specifying an array in this way causes SAS
to treat the array as a list of the variables
instead of processing only one element of the
array at a time. - array y10 y1-y10
- xsum(of y)
9Syntax of CALL Routines
- CALL routine-name (argument-1lt. . .,argument-ngt)
- where
- routine-name names a SAS CALL routine.
- argument can be a variable name, a constant, any
SAS expression, an external module name, an array
reference, or a function. Multiple arguments are
separated by a comma.
10Probability (1)
- CDF Computes cumulative distribution functions
- CDF ('dist',quantile,parm-1, . . . ,parm-k)
- ycdf('BINOM',4,.5,10)
- PDF Computes probability density (mass)
functions - PDF ('dist',quantile,parm-1, . . . ,parm-k)
- zpdf('NORMAL',1.96)
P(Ylt4)0.37695, if YB(10,.5)
fz(1.96)0.058441, if ZN(0,1)
11Probability (2)
- POISSON Returns the probability from a Poisson
distribution - POISSON(lambda,k)
- xpoisson(1,2)
- PROBBNML Returns the probability from a binomial
distribution - PROBBNML(p,n,k)
- xprobbnml(0.5,10,4)
P(X2)0.9196986029, if XP(1)
P(X4)0.376953125, if XB(10,.5)
12Probability (3)
- PROBNORM Returns the probability from the
standard normal distribution - PROBNORM(x)
- xprobnorm(1.96)
- PROBCHI Returns the probability from a
chi-squared distribution - PROBF Returns the probability from an F
distribution - PROBT Returns the probability from a t
distribution
P(Xlt1.96)0.9750021049, if XN(0,1)
13Quantile
- PROBIT Returns a quantile from the standard
normal distribution - PROBIT(p)
- xprobit(.025)
- CINV Returns a quantile from the chi-squared
distribution - FINV Returns a quantile from the F distribution
- TINV Returns a quantile from the t distribution
fx (-1.959963985 )0.025, if XN(0,1)
14Assignment
- Create a series of numbers (x) between 3 and 3
(-3.0, -2.9, -2.8, .., 2.8,2.9,3.0) in EXCEL,
and read in the file into SAS - Compute the p.d.f. for the above xs by assuming
XN(0,1) - Generate a 2-way scatter plot p.d.f. of X vs X
- Find a z value that cut off the lower tail of 10
of a standard normal distribution