Date: Fri, 8 May 1998 12:32:00 -0400
Reply-To: "Barless, A. (Allan)" <ALLAN.BARLESS@ROYALBANK.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: "Barless, A. (Allan)" <ALLAN.BARLESS@ROYALBANK.COM>
Subject: printing merge mismatches
Content-Type: text/plain
One way to handle this is to use keep or drop dataset options. For
example:
data both
only1 (keep = keyvar1 onevar1 onevar2 onevar3 ... )
only2 (drop = onevar1 onevar2 onevar3 ...)
;
merge one(in=3Din1) two(in=3Din2);
by ssn;
if in1 and not in2 then output only1;
else if in2 and not in1 then output only2; else output both;
run;
Proc print data=3Donly1;
Proc print data=3Donly2;
Two things to notice. I make sure I don't drop the key
variable in the third dataset. You will want this for
identification.
Second I use a keep once and a drop once. This is so that if
I have a lot of variable names I only need to type them in
once. I can copy/paste them into the drop from the keep.
I hope this helps.
Al B
______________________________ Forward Header
__________________________________
Subject: printing merge mismatches
Author: SMTP:Lnonnemaker@AAMC.ORG at Internet
Date: 08/05/98 11:49 AM
I often have occasion to merge two data sets, check for
mismatches, and printing info on records that don't match up.
The code I use is:
****;
Data both only1 only2;
merge one(in=3Din1) two(in=3Din2);
by ssn;
if in1 and not in2 then output only1;
else if in2 and not in1 then output only2;
else output both;
run;
Proc print data=3Donly1;
Proc print data=3Donly2;
***;
The trouble with this code is that when I print, I get all the variables
=
from both data sets in the merge, with half of them
missing. I need to add a var statement to the print(or a keep option to
=
the data statement) listing all the variables that should have good =
info.=20
I am looking for suggestions on a way to tell SAS to print only the =
variables that aren't all missing, or to otherwise recognize that I
don't =
want the variables from the dataset in which the record was not found.
Any ideas?=20
TIA,
Lynn
*************************************************
Lynn Nonnemaker, Ph.D.
Research Associate
Association of American Medical Colleges
2450 N Street, NW
Washington, DC 20037
LNonnemaker@aamc.org