EDIT
SAS-data-set <VAR operand> <WHERE(expression)> <NOBS name> ;
The EDIT statement opens a SAS data set for reading and updating. If the data set has already been opened, the EDIT statement makes it the current input and output data sets.
The EDIT statement can define a set of variables and the selection criteria that are used to control access to data set observations.
The VAR, WHERE, and NOBS clauses are optional. and can be specified in any order.
The arguments to the EDIT statement are as follows:
specifies a SAS data set. You can specify a one-level name (for example, A) or a two-level name (for example, Sasuser.A). You can also specify an expression (enclosed in parentheses) that resolves to the name of a SAS data set. See the example for the CLOSE statement.
specifies a set of variables to edit. You can specify variables by using any of the methods described in the section Select Variables with the VAR Clause.
specifies observations to edit. If you omit the WHERE clause, all observations are selected. For more details about the WHERE clause, see the section Process Data by Using the WHERE Clause.
specifies a variable to contain the number of observations. The NOBS clause returns the total number of observations in the data set in the variable name.
For example, to read and update observations for which the Age
variable is greater than 30, use the following statements:
proc iml; /* create sample data set */ sex = { M, M, M, F, F, F}; age = {34, 28, 38, 32, 24, 18}; create MyData var {"Sex" "Age"}; append; close MyData; edit MyData where (Age>30); list all; close MyData;
Figure 24.115: Result of the LIST Statement
OBS Sex Age ------ --- --------- 1 M 34.0000 3 M 38.0000 4 F 32.0000 |
To edit the data set Work.MyData
and obtain the number of observations in the data set, use the following statements:
edit Work.MyData nobs NumObs; close Work.MyData; print NumObs;
See Chapter 7 for more information about editing SAS data sets. For additional examples of using the EDIT statement, see the DELETE statement and the REPLACE statement.