![]() | ![]() | ![]() | ![]() | ![]() |
Use IN= logic to determine if the current BY-Group is found in
both data sets.
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 one;
input id $ name $ dept $ project $;
datalines;
000 Miguel A12 Document
111 Fred B45 Survey
222 Diana B45 Document
888 Monique A12 Document
999 Vien D03 Survey
;
data two;
input id $ name $ projhrs;
datalines;
111 Fred 35
222 Diana 40
777 Steve 0
888 Monique 37
999 Vien 42
;
data both one_only two_only;
merge one(in=in1) two(in=in2);
by id;
if in1 and in2 then output both;
else if in1 then output one_only;
else output two_only;
run;
title 'Both';
proc print data=both;
run;
title 'One only';
proc print data=one_only;
run;
title 'Two only';
proc print data=two_only;
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.
Both Obs id name dept project projhrs 1 111 Fred B45 Survey 35 2 222 Diana B45 Document 40 3 888 Monique A12 Document 37 4 999 Vien D03 Survey 42 One only Obs id name dept project projhrs 1 000 Miguel A12 Document . Two only Obs id name dept project projhrs 1 777 Steve 0
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Statements ==> File-handling ==> MERGE Common Programming Tasks ==> Combining Data SAS Reference ==> Statements ==> File-handling ==> MERGE ==> with IN= Common Programming Tasks ==> Selecting Data |
| Date Modified: | 2011-11-21 13:26:26 |
| Date Created: | 2004-09-30 14:09:03 |
| Product Family | Product | Host | SAS Release | |
| Starting | Ending | |||
| SAS System | Base SAS | All | n/a | n/a |





