Sample 24669: Performing a lookup against a data set containing duplicates
Locate all matches in an indexed data set based upon values from
a lookup data set.
Note:
When the master data set contains duplicate values, only the
first matching observation of the KEY value is updated.
To force a continuous search of the master index file,
use a DO loop until a non-match condition is encountered.
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.
data primary(index=(partno));
input partno $ desc $;
datalines;
A021 motor
A033 bolt
A043 nut
A055 radiator
A066 hose
A066 hose2
A066 hose3
A078 knob
A220 switch
A223 bridge
;
data lookup;
input partno $ quantity;
datalines;
A066 8
A220 2
A812 10
;
data combine;
set lookup;
do until(_iorc_=%sysrc(_dsenom));
set primary key=partno;
select(_iorc_);
when (%sysrc(_sok)) do;
output;
end;
when (%sysrc(_dsenom)) do;
_error_=0;
end;
otherwise;
end;
end;
run;
proc print data=combine;
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 partno quantity desc
1 A066 8 hose
2 A066 8 hose2
3 A066 8 hose3
4 A220 2 switch
Locate all matches in an indexed data set based upon values from
a lookup data set.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> SET ==> with KEY= SAS Reference ==> Statements ==> File-handling ==> SET Data Management ==> Manipulation and Transformation ==> Combining and Modifying Data Sets
|
| Date Modified: | 2005-12-08 11:34:19 |
| Date Created: | 2004-09-30 14:09:02 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |