Sample 24792: Update a data set in place based upon observation number
Using observation numbers, modify an existing data set with
values from a second 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.
/********************************************************************************/
/* The POINT= option allows you to access observations in a master */
/* data set by observation number. The value for POINT= comes from a data */
/* set on a SET statement. */
/* */
/* Logic is included to detect invalid POINT= values or _ERROR_. Pointing */
/* to an observation already marked for deletion will trigger _ERROR_. */
/* */
/* This example reads the data set NEWP, determines which observation number in */
/* STOCK to update based on the value of TOOL_OBS, and performs the update. */
/* This example explicitly specifies the update activity by using an assignment */
/* statement to replace the value of PRICE with the value of NEWP. */
/********************************************************************************/
data stock;
input tool $ 1-12 price;
datalines;
Screw driver 4.00
Power drill 55.00
Garden hose 14.99
;
data newp;
input tool_obs newp;
datalines;
2 51.00
2 49.33
3 12.32
4 30.00
;
data stock;
set newp;
modify stock point=tool_obs nobs=obs;
if tool_obs LT 1 or tool_obs GT obs then
put "TOOL_OBS value is out of range. POINT= value was " tool_obs +(-1)".";
if _ERROR_=1 then do;
_ERROR_=0;
stop;
end;
price=newp;
run;
proc print data=stock;
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 tool price
1 Screw driver 4.00
2 Power drill 49.33
3 Garden hose 12.32
Using observation numbers, modify an existing data set with
values from a second data set.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> MODIFY Common Programming Tasks ==> Combining Data SAS Reference ==> Statements ==> File-handling ==> MODIFY ==> with POINT=
|
| Date Modified: | 2008-01-25 14:39:47 |
| Date Created: | 2004-09-30 14:09:14 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |