Sample 24686: Using MODIFY with KEY= and SET with POINT= to apply transactions to a master data set with common variable names
Update a MASTER data set in place, replacing any
observations whose value of the key variable ID matches
the value of ID stored in the TRANS data set. Both data
sets may contain mulitple observations for some values of
the KEY variable's value.
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.
/********************************************************************/
/* This technique uses MODIFY and a SET with POINT=. The SET with */
/* POINT= is used to update like-named variables when you use KEY= */
/* (which is not automatically done with KEY=). */
/********************************************************************/
data master(index=(initial));
input girl $ ;
length guy $8 initial $1; /* GUY needs to be on PDV for MODIFY */
initial=substr(girl,1,1);
datalines;
April
Amy
Anne
Beth
Beatrice
Candace
Delta
Dawn
Dee
Edwina
Eunice
;
data trans;
input guy $;
length initial $1;
initial=substr(guy,1,1);
datalines;
Albert
Ben
Bert
Cal
Clark
Craig
Dirk
Don
Ephram
;
data master ;
set trans;
modify master key=initial;
i +1;
if _IORC_=%sysrc(_sok) then do;
set trans point=i;
replace;
end;
else _ERROR_=0;
run;
proc print data=master;
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 girl guy initial
1 April Albert A
2 Amy A
3 Anne A
4 Beth Ben B
5 Beatrice Bert B
6 Candace Cal C
7 Delta Dirk D
8 Dawn Don D
9 Dee D
10 Edwina Ephram E
11 Eunice E
Update a MASTER data set in place, replacing any
observations whose value of the key variable ID matches
the value of ID stored in the TRANS data set. Both data
sets may contain mulitple observations for some values of
the KEY variable's value.
| 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 KEY= SAS Reference ==> Statements ==> File-handling ==> SET SAS Reference ==> Statements ==> File-handling ==> SET ==> with POINT=
|
| Date Modified: | 2008-01-25 14:38:13 |
| Date Created: | 2004-09-30 14:09:04 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |