Sample 24784: Update a master data set with transactions from another data set based upon a common variable
Overlay values in master data set with non-missing
values from a second data set.
UPDATE uses observations from the transaction data
set to change the values of the corresponding
observations from the master data set. You must
use a BY statement. Data needs to be in sorted
order, or indexed.
UPDATE works with two data sets only.
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.
/* The BEGIN data set contains ID's and starting weights for */
/* diet patients. As they begin to lose weight, the original */
/* data set needs to be updated with the new weight for each */
/* patient (ID) that lost weight. */
data begin;
input id weight;
datalines;
111 243
222 192
333 165
444 289
555 310
;
data weighin;
input id weight;
datalines;
111 236
222 .
333 158
555 294
;
/* Note WEIGHT for ID 222 will not be overwritten */
/* with the missing value from WEIGHIN. */
data new;
update begin weighin;
by id;
run;
proc print data=new;
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 id weight
1 111 236
2 222 192
3 333 158
4 444 289
5 555 294
Overlay values in master data set with non-missing
values from a second data set.
Type: | Sample |
Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> UPDATE Common Programming Tasks ==> Combining Data
|
Date Modified: | 2008-01-28 11:44:27 |
Date Created: | 2004-09-30 14:09:14 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |