SAS Functions Syntax

Arguments, Variable Lists, Arrays

To use a SAS function, specify the function name followed by the function arguments, which are enclosed in parentheses.
Syntax, SAS function:
function-name(argument-1<,argument-n>);
Each of the following are arguments.
  • variables, mean(x,y,z)
  • constants, mean(456,502,612,498)
  • expressions, mean(37*2,192/5,mean(22,34,56))
Note: Even if the function does not require arguments, the function name must still be followed by parentheses (for example, function-name()).
When a function contains more than one argument, the arguments are usually separated by commas.
function-name(argument-1,argument-2,argument-n)
In some functions, variable lists and arrays can also be used as arguments, as long as the list or the array is preceded by the word of. For more information about arrays, see Processing Data with Arrays.

Example: Multiple Arguments

Here is an example of a function that contains multiple arguments. Notice that the arguments are separated by commas.
mean(x1,x2,x3)
The arguments for this function can also be written as a variable list.
mean(of x1-x3)
As an alternative, the variables can be referenced by an array.
mean(of newarray{*})

Target Variables

A target variable is the variable to which the result of a function is assigned. For example, in the statement below, the variable AvgScore is the target variable.
AvgScore=mean(exam1,exam2,exam3);
Unless the length of the target variable has been previously defined, a default length is assigned. The default length depends on the function; the default for character functions can be as long as 200.
Tip
Default lengths can cause character variables to use more space than necessary in your data set. So, when using SAS functions, consider the appropriate length for any character target variables. If necessary, add a LENGTH statement to specify a length for the character target variable before the statement that creates the values of that variable.
Last updated: January 10, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.81.33