Sample 24687: Using the MODIFY statement to update all observations in a data set
Update a data set in place using MODIFY statement.
Note:
The MODIFY statement opens SAMPLE for update processing.
SAS reads one observation of SAMPLE for each iteration of
the DATA step and performs any operations that the code
specifies. In this case, the code replaces numeric missings
with zero. An implicit REPLACE statement at the end of the
step writes each observation to its previous location in
SAMPLE.
In this example, using MODIFY is much like using a SET
statement, yet saves disk space resources by not rebuilding
the data set.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/* Create sample data set */
data sample;
input x y z;
datalines;
1 2 3
. 22 .
. . .
;
data sample;
modify sample;
array num(3) x y z;
do i=1 to 3;
if num(i)=. then num(i)=0;
end;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs x y z
1 1 2 3
2 0 22 0
3 0 0 0
Update a data set in place using MODIFY statement
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> MODIFY Common Programming Tasks ==> Combining Data
|
| Date Modified: | 2005-12-08 11:34:21 |
| Date Created: | 2004-09-30 14:09:04 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |