0% found this document useful (0 votes)
51 views

Sas Functions: Excerpted From SAS Release 8.2 Online Documentation July, 2004

This document provides a summary of SAS functions organized into categories such as arithmetic, character, date/time, and statistical functions. It lists the function name, description, and arguments. For example, ABS(argument) returns the absolute value and DATE() returns the current date as a SAS date value. The document also includes tips for using state and ZIP code conversion functions.

Uploaded by

Hariom Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

Sas Functions: Excerpted From SAS Release 8.2 Online Documentation July, 2004

This document provides a summary of SAS functions organized into categories such as arithmetic, character, date/time, and statistical functions. It lists the function name, description, and arguments. For example, ABS(argument) returns the absolute value and DATE() returns the current date as a SAS date value. The document also includes tips for using state and ZIP code conversion functions.

Uploaded by

Hariom Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

SAS FUNCTIONS

Excerpted from SAS release 8.2 Online Documentation


ul!" 2##$
Arit%metic Functions
ABS(argument) returns absolute value
DIM<n>(array-name) returns the number of elements in a one-dimensional array or the number of
elements in a speified dimension of a multidimensional array!
n speifies the dimension" in a multidimensional array" for
#hih you #ant to $no# the the number of elements!
DIM(array-name"bound-n) returns the number of elements in a one-dimensional array or the number of
elements in the speified dimension of a multidimensional array
&ound'n speifies the dimension in a multidimensional array"
for #hih you #ant to $no# the number of elements!
%B&'(D<n>(array-name) returns the upper bound of an array
%B&'(D(array-
name"bound-n)
returns the upper bound of an array
)B&'(D<n>(array-name) returns the lo#er bound of an array
)B&'(D(array-
name"bound-n)
returns the lo#er bound of an array
MA*(argument"argument" !!!
)
returns the largest value of the numeri arguments
MI((argument"argument" !!!) returns the smallest value of the numeri arguments
M&D(argument-+"
argument-,)
returns the remainder
SI-((argument) returns the sign of a value or .
S/01(argument) returns the s2uare root
C%aracter Functions
B314(n) returns one harater in the AS5II or 4B5DI5
ollating se2uene #here nis an integer representing
a speifi AS5II or 4B5DI5 harater
5&))A14(start-position<"end-position>) 6 (start-
position<""length>)
returns an AS5II or 4B5DI5 ollating se2uene
harater string
5&M7B)(soure) removes multiple blan$s bet#een #ords in a
+
harater string
5&M704SS(soure<"haraters-to-remove>) removes speifi haraters from a harater string
D4/'&14(argument) removes 2uotation mar$s from a harater value
I(D4*(soure"e8erpt) searhes the soure for the harater string speified
by the e8erpt
I(D4*5(soure"e8erpt-+<" !!! e8erpt-n>) searhes the soure for any harater present in the
e8erpt
I(D4*9(soure"e8erpt) searhes the soure for a speified pattern as a #ord
)4:1(argument) left-aligns a SAS harater string
)4(-1%(argument) returns the length of an argument
)&95AS4(argument) onverts all letters in an argument to lo#erase
/'&14(argument) adds double 2uotation mar$s to a harater value
0A(;(8) returns the position of a harater in the AS5II or
4B5DI5 ollating se2uene
0474A1(argument"n) repeats a harater e8pression
04<40S4(argument) reverses a harater e8pression
0I-%1(argument) right-aligns a harater e8pression
S5A((argument"n<"delimiters>) returns a given #ord from a harater e8pression
S&'(D4*(argument) enodes a string to failitate searhing
S'BS10(argument"position<"n>)=haraters-to-
replae
replaes harater value ontents
var=S'BS10(argument"position<"n>) e8trats a substring from an argument! (var is any
valid SAS variable name!)
10A(S)A14(soure"to-+"from-+<"!!!to-n"from-n>) replaes speifi haraters in a harater
e8pression
10A(90D(soure"target"replaement) replaes or removes all ourrenes of a #ord in a
harater string
10IM(argument) removes trailing blan$s from harater e8pression
and returns one blan$ if the e8pression is missing
10IM((argument) removes trailing blan$s from harater e8pressions
and returns a null string if the e8pression is missing
'75AS4(argument) onverts all letters in an argument to upperase
<40I:3(soure"e8erpt-+<"!!!e8erpt-n) returns the position of the first harater uni2ue to
an e8pression
Date and Time Functions
DA1DI:(sdate"edate"basis) returns the number of days bet#een t#o dates
,
DA14() returns the urrent date as a SAS date value
DA14>')(?ulian-date) onverts a >ulian date to a SAS date value
DA147A01(datetime) e8trats the date from a SAS datetime value
DA141IM4() returns the urrent date and time of day
DA3(date) returns the day of the month from a SAS date value
D%MS(date"hour"minute"seond) returns a SAS datetime value from date" hour" minute" and
seond
%MS(hour"minute"seond) returns a SAS time value from hour" minute" and seond
%&'0(<time 6 datetime>) returns the hour from a SAS time or datetime value
I(15;(@interval@"from"to) returns the number of time intervals in a given time span
I(1(*(@interval@"start-
from"inrement<"@alignment@>)
advanes a date" time" or datetime value by a given interval"
and returns a date" time" or datetime value
>')DA14(date) returns the >ulian date from a SAS date value
MD3(month"day"year) returns a SAS date value from month" day" and year values
MI('14(time 6 datetime) returns the minute from a SAS time or datetime value
M&(1%(date) returns the month from a SAS date value
/10(date) returns the 2uarter of the year from a SAS date value
S45&(D(time 6 datetime) returns the seond from a SAS time or datetime value
1IM4() returns the urrent time of day
1IM47A01(datetime) e8trats a time value from a SAS datetime value
1&DA3() returns the urrent date as a SAS date value
944;DA3(date) returns the day of the #ee$ from a SAS date value
34A0(date) returns the year from a SAS date value
30DI:(sdate"edate"basis) returns the differene in years bet#een t#o dates
33/(year"2uarter) returns a SAS date value from the year and 2uarter
(at%ematical Functions
AI03(8) returns the value of the AI03 funtion
DAI03(8) returns the derivative of the AI03 funtion
DI-AMMA(argument) returns the value of the DI-AMMA funtion
40:(argument) returns the value of the (normal) error funtion
40:5(argument) returns the value of the (normal) error funtion
4*7(argument) returns the value of the e8ponential funtion
-AMMA(argument) returns the value of the -AMMA funtion
A
IB4SS4)(nu"8"$ode) returns the value of the modified bessel funtion
>B4SS4)(nu"8) returns the value of the bessel funtion
)-AMMA(argument) returns the natural logarithm of the -AMMA funtion
)&-(argument) returns the natural (base e) logarithm
)&-,(argument) returns the logarithm to the base ,
)&-+.(argument) returns the logarithm to the base +.
10I-AMMA(argument
)
returns the value of the 10I-AMMA funtion
Noncentralit! Functions
5(&(51(8"df"prob) returns the nonentrality parameter from a hi-s2uared distribution
:(&(51(8"ndf"ddf"prob) returns the value of the nonentrality parameter of an : distribution
1(&(51(8"df"prob) returns the value of the nonentrality parameter from the student@s t
distribution
)ro&a&ilit! and Densit! Functions
5D:(@dist@"2uantile"parm-+"!!!"parm-$) omputes umulative distribution funtions
)&-7D:6)&-7M:(@dist@"2uantile"parm-
+"!!!"parm-$)
omputes the logarithm of a probability density (mass)
funtion! 1he t#o funtions are idential!
)&-SD:(@dist@"2uantile"parm-+"!!!"parm-$) omputes the logarithm of a survival funtion
7D:67M:(@dist@"2uantile"parm-+"!!!"parm-$) omputes probability density (mass) funtions
7&ISS&((m"n) returns the probability from a 7&ISS&( distribution
70&BB41A(8"a"b) returns the probability from a beta distribution
70&BB(M)(p"n"m) returns the probability from a binomial distribution
70&B5%I(8"df<"n>) returns the probability from a hi-s2uared distribution
70&B:(8"ndf"ddf<"n>) returns the probability from an : distribution
70&B-AM(8"a) returns the probability from a gamma distribution
70&B%370((";"n"8<"r>) returns the probability from a hypergeometri distribution
70&BM5 probabilities and ritial values (2uantiles) from various
distributions for multiple omparisons of the means of
several groups!
70&B(4-B(p"n"m) returns the probability from a negative binomial
distribution
70&BB(0M(8"y"r) standardiBed bivariate normal distribution
70&B(&0M(8) returns the probability from the standard normal
C
distribution
70&B1(8"df<"n>) returns the probability from a Student@s t distribution
SD:(@dist@"2uantile"parm-+"!!!"parm-$) omputes a survival funtion
*uantile Functions
B41AI(<(p"a"b) returns a 2uantile from the beta distribution
5I(<(p"df<"n>) returns a 2uantile from the hi-s2uared distribution
:I(<(p"ndf"ddf<"n>
)
returns a 2uantile from the : distribution
-AMI(<(p"a) returns a 2uantile from the gamma distribution
70&BI1(p) returns a 2uantile from the standard normal distribution
1I(<(p"df<"n>) returns a 2uantile from the t distribution
Sample Statistics Functions
5SS(argument"argument"!!!) returns the orreted sum of s2uares
5<(argument"argument"!!!) returns the oeffiient of variation
;'01&SIS(argument"argument"!!!) returns the $urtosis (or Cth moment)
MA*(argument"argument" !!!) returns the largest value
MI((argument"argument" !!!) returns the smallest value
M4A((argument"argument" !!!) returns the arithmeti mean (average)
MISSI(-(numeri-e8pression 6 harater-
e8pression)
returns a numeri result that indiates #hether the
argument ontains a missing value
((argument"argument" !!!!) returns the number of nonmissing values
(MISS(argument"argument" !!!) returns the number of missing values
&0DI(A)(ount"argument"argument"!!!) returns the largest value of a part of a list
0A(-4(argument"argument"!!!) returns the range of values
S;49(4SS(argument"argument"argument"!!!) returns the s$e#ness
S1D(argument"argument"!!!) returns the standard deviation
S1D400(argument"argument"!!!) returns the standard error of the mean
S'M(argument"argument"!!!) returns the sum
'SS(argument"argument"!!!) returns the unorreted sum of s2uares
<A0(argument"argument"!!!) returns the variane
D
State and +I) Code Functions
:I7(AM4(e8pression) onverts :I7S odes to upperase state names
:I7(AM4)(e8pression) onverts :I7S odes to mi8ed ase state names
:I7S1A14(e8pression) onverts :I7S odes to t#o-harater postal odes
S1:I7S(postal-ode) onverts state postal odes to :I7S state odes
S1(AM4(postal-ode) onverts state postal odes to upperase state names
Tip, :or <ersion E" the ma8imum length of the value that is
returned is ,.. haraters! :or <ersion F and beyond" the
ma8imum length is ,. haraters!
S1(AM4)(postal-
ode)
onverts state postal odes to mi8ed ase state names
Tip, :or <ersion E" the ma8imum length of the value that is
returned is ,.. haraters! :or <ersion F and beyond" the
ma8imum length is ,. haraters!
GI7:I7S(Bip-ode) onverts GI7 odes to :I7S state odes
GI7(AM4(Bip-ode) onverts GI7 odes to upperase state names
GI7(AM4)(Bip-ode) onverts GI7 odes to mi8ed ase state names
GI7S1A14(Bip-ode) onverts GI7 odes to state postal odes
Tri-onometric and .!per&olic Functions
A05&S(argument) returns the arosine
A0SI((argument) returns the arsine
A1A((argument) returns the artangent
5&S(argument) returns the osine
5&S%(argument) returns the hyperboli osine
SI((argument) returns the sine
SI(%(argument) returns the hyperboli sine
1A((argument) returns the tangent
1A(%(argument) returns the hyperboli
tangent
Truncation Functions
54I)(argument) returns the smallest integer that is greater than or e2ual to the
argument
:)&&0(argument) returns the largest integer that is less than or e2ual to the argument
E
:'GG(argument) returns the nearest integer if the argument is #ithin +4-+,
I(1(argument) returns the integer value
0&'(D(argument"round-off-
unit)
rounds to the nearest round-off unit
10'(5(number" length) trunates a numeri value to a speified length
/aria&le Information Functions
-41<A05(data-set-id"var-num) returns the value of a SAS data set harater variable
-41<A0((data-set-id"var-num) returns the value of a SAS data set numeri variable
<A0:M1(data-set-id"var-num) returns the format assigned to a SAS data set variable
<A0I(:M1(data-set-id"var-
num)
returns the informat assigned to a SAS data set variable
<A0)AB4)(data-set-id"var-
num)
returns the label assigned to a SAS data set variable
<A0)4((data-set-id"var-num) returns the length of a SAS data set variable
<A0(AM4(data-set-id"var-
num)
returns the name of a SAS data set variable
<A0('M(data-set-id"var-name) returns the number of a SAS data set variable@s position in a SAS data
set
<A00A3(name) returns a value that indiates #hether the speified name is an array
<A00A3*(e8pression) returns a value that indiates #hether the value of the speified
argument is an array
<A01374(data-set-id"var-num) returns the data type of a SAS data set variable
<:&0MA1(var) returns the format assoiated #ith the given variable
<:&0MA1D(var) returns the format deimal value assoiated #ith the given variable
<:&0MA1D*(e8pression) returns the format deimal value assoiated #ith the value of the
speified argument
<:&0MA1((var) returns the format name assoiated #ith the given variable
<:&0MA1(*(e8pression) returns the format name assoiated #ith the value of the speified
argument
<:&0MA19(var) returns the format #idth assoiated #ith the given variable
<:&0MA19*(e8pression) returns the format #idth assoiated #ith the value of the speified
argument
<:&0MA1*(e8pression) returns the format assoiated #ith the value of the speified argument
<I(A00A3(var) returns a value that indiates #hether the given variable is a member of
an array
<I(A00A3*(e8pression) returns a value that indiates #hether the value of the speified
F
argument is a member of an array
<I(:&0MA1(var) returns the informat assoiated #ith the given variable
<I(:&0MA1D(var) returns the informat deimal value assoiated #ith the given variable
<I(:&0MA1D*(e8pression) returns the informat deimal value assoiated #ith the value of the
speified argument
<I(:&0MA1((var) returns the informat name assoiated #ith the given variable
<I(:&0MA1(*(e8pression) returns the informat name assoiated #ith the value of the speified
argument
<I(:&0MA19(var) returns the informat #idth assoiated #ith the given variable
<I(:&0MA19*(e8pression) returns the informat #idth assoiated #ith the value of the speified
argument
<I(:&0MA1*(e8pression) returns the informat assoiated #ith the value of the speified argument
<)AB4)(var) returns the label assoiated #ith the given variable
<)AB4)*(e8pression) returns the variable label for the value of a speified argument
<)4(-1%(var) returns the ompile-time (alloated) siBe of the given variable
<)4(-1%*(e8pression) returns the ompile-time (alloated) siBe for the value of the speified
argument
<(AM4(var) returns the name of the given variable
<(AM4*(e8pression) validates the 0alue of the speified argument as a variable name
<1374(var) returns the type (harater or numeri) of the given variable
<1374*(e8pression) returns the type (harater or numeri) for the value of the speified
argument
H

You might also like