Date: Tue, 3 Aug 1999 09:37:42 -0400
Reply-To: HEATONE <HEATONE@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: HEATONE <HEATONE@WESTAT.COM>
Subject: Re: Combining Data Sets while excluding obs
Content-Type: text/plain; charset=US-ASCII
Rob;
Consider the following code.
DATA mothers ;
ATTRIB
name LABEL= "Name"
LENGTH= $ 20
home LABEL= "Household"
;
INFILE CARDS ;
INPUT
@ 10 name $20.
@ 30 home
;
CARDS ;
Clare's mother 3
nobody's mother 6
Anna's mother 1
Emma's mother 5
Betty's mother 2
Deb's mother 4
;
RUN ;
DATA daughtrs ;
ATTRIB
name LABEL= "Name"
LENGTH= $ 20
home LABEL= "Household"
;
INFILE CARDS ;
INPUT
@ 10 name $20.
@ 30 home
;
CARDS ;
Emma 5
Anna 1
Deb 4
orphan child 7
Clare 3
Betty 2
;
RUN ;
PROC SQL ;
CREATE TABLE matches AS
SELECT mothers.*
FROM mothers, daughtrs
WHERE mothers.home EQ daughtrs.home
OUTER UNION CORRESPONDING
SELECT daughtrs.*
FROM mothers, daughtrs
WHERE mothers.home EQ daughtrs.home
;
SELECT * FROM matches ; /* Print the results. */
QUIT ;
Hope this helps,
Ed
Edward Heaton, Sr. Systems Analyst,
Westat (An Employee-Owned Research Corporation),
1550 Research Boulevard, Room 2018, Rockville, MD 20850-3159
voice: (301) 610-4818 fax: (301) 294-3992
mailto:heatone@westat.com http://www.westat.com
____________________Reply Separator____________________
Subject: Combining Data Sets while excluding obs
Author: "Robert Andrew Bowell Jr." <bowell@NBCS.RUTGERS.EDU>
Date: 8/3/1999 8:23 AM
Hi,
I have a user who needs to combine 2 data sets, a mothers data set
and a daughters data set, which are formatted exactly the same (the same
variables). She wants to exclude from the combined set people who aren't
related to each other. There's a variable for each observation in both
data sets that codes for what household you live in. There's also a
variable to code what household your mother lived in. So what she needs
to do, for a given observation in the daughter data set, is to have SAS
look at the "mother's home" variable, see if it exists in the mother data
set under "home", and if not, drop the observation. Similarly, for a
given observation in the mothers data set, it needs to look at the "home"
variable and see if it exists within the daughters data set under the
"mother's home" variable.
Any idea how to do this?
Y'obt.,
Rob Bowell
-------------------------------------------------
Programmer/Analyst, RUCS User Services Group
Hill Center, Room 209
Phone: 732-445-0481/Fax: 732-445-5539
-------------------------------------------------
|