Language Reference

USE Statement

opens a SAS data set for reading

USE SAS-data-set <VAR operand> <WHERE(expression)>
           <NOBS name>;

The inputs to the USE statement are as follows:
can be specified with a one-level name (for example, A) or a two-level name (for example, SASUSER.A). For more information about specifying SAS data sets, see the chapter on SAS data sets in SAS Language Reference: Concepts.

selects a set of variables.

is evaluated for being true or false.

is the name of a variable to contain the number of observations.
If the data set has not already been opened, the USE statement opens the data set for read access. The USE statement also makes the data set the current input data set so that subsequent statements act on it. The USE statement optionally can define selection criteria that are used to control access.

The VAR clause specifies a set of variables to use, where operand can be any of the following: The following examples demonstrate each possible way you can use the VAR clause:
    var {time1 time5 time9}; /* a literal giving the variables */ 
    var time;                /* a matrix containing the names  */ 
    var('time1':'time9');    /* an expression                  */ 
    var _all_;               /* a keyword                      */
The WHERE clause conditionally selects observations, within the range specification, according to conditions given in the clause. The general form of the WHERE clause is as follows:

WHERE( variable comparison-op operand)

In the preceding statement,
is a variable in the SAS data set.

is one of the following comparison operators:

less than

less than or equal to

equal to

greater than

greater than or equal to

not equal to

contains a given string

does not contain a given string

begins with a given string

sounds like or is spelled like a given string

is a literal value, a matrix name, or an expression in parentheses.

WHERE comparison arguments can be matrices. For the following operators, the WHERE clause succeeds if all the elements in the matrix satisfy the condition:

 ^=   ^?   <   <=   >   >=

For the following operators, the WHERE clause succeeds if any of the elements in the matrix satisfy the condition:

 =   ?   =:   =*

Logical expressions can be specified within the WHERE clause by using the AND (&) and OR (|) operators. The general form is

 clause&clause(for an AND clause)
 clause|clause(for an OR clause)

where clause can be a comparison, a parenthesized clause, or a logical expression clause that is evaluated by using operator precedence.

Note: The expression on the left-hand side refers to values of the data set variables, and the expression on the right-hand side refers to matrix values.

The VAR and WHERE clauses are optional, and you can specify them in any order. If a data set is already open, all the options that the data set was first opened with are still in effect. To override any old options, the new USE statement must explicitly specify the new options. Examples of valid statements follow.

    use class; 
    use class var{name sex age}; 
    use class var{name sex age} where(age>10);

Previous Page | Next Page | Top of Page