| Date: | Wed, 2 Jul 1997 13:48:17 -0400 |
| Reply-To: | Victor Kamensky <kamensky@AECOM.YU.EDU> |
| Sender: | "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU> |
| From: | Victor Kamensky <kamensky@AECOM.YU.EDU> |
| Subject: | Re: merging mothers and babies |
| Content-Type: | text/plain; charset="us-ascii" |
|---|
Sorry if it is second posting.
But I received 2 messages that my mail failed.
Hi,Karen!
If you want to have one record per mother and keep mother age at each baby's
birth
you have to set a limit -MAXCHILD-i,e. maximal number of children. The
program will look like the following(not tested):
data mothers;
merge mothers babies;
by motherid;
bir_age=(child_birth_date - mother_birth_date)/365.25;
*this is the convention for calculating age in SAS Language manual;
run;
proc sort data=mothers; by motherid;by motherid child_birth_date;run;
%let MAXCHILD=10;
data mothers; set mothers;by motherid;
array b_age b_age1-b_age&MAXCHILD;
retain b_age1-b_age&MAXCHILD numchild;
if first.motherid then do ;numchild=0;
do over b_age; b_age=.;end;
end;
numchild+1; b_age(numchild)=bir_age;
drop bir_age;
if last.motherid;
run;
Sincerely
Victor Kamensky
Programmer
Albert Einstein College of Medicine
At 09:21 AM 7/2/97 EST, you wrote:
>I'm having trouble thinking logically about this.
>I have a file with baby info, 1 record per baby. Included in this file
>is a mother id. I have another file with mother info, 1 record per mother.
>Because of multiple births, there are more babies than mothers. I want
>to calculate mother age at baby's birth and need to get baby's birthday
>out of the baby file. When I merge the two files by mother id, I get
>extra mother records for the multiple births.
>How do I merge the files and keep only 1 record per mother id in the
>merged file?
>
>And while I'm writing, is there a convention for calculating age? A few
>days off for leap years doesn't matter here, but as long as I'm writing
>the program, might as well be exact.
>
>Thanks for any help.
>Karen Olson
>Children's Hospital, Boston, MA
>olson_k@a1.tch.harvard.edu
>
>
|