LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 16 Jun 2010 12:22:15 -0400
Reply-To:   msz03@albany.edu
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mike Zdeb <msz03@ALBANY.EDU>
Subject:   Re: Sorry: title is "Counting mothers from babies"
Content-Type:   text/plain;charset=iso-8859-1

hi ... from my experience with this type of data, it's not an easy problem as it looks since there are often infant records with a plurality greater than 1, but the corresponding record(s) for the other twin, triplet, quad is(are) not on the the live birth data file since the other twin, triplet, quad was not a live birth .., rather a fetal death an that record is in another file

so, it's not uncommon for there to be only two live births in the file with a plurality of 3, but the third outcome is a fetal death

if you are willing to ignore the above ...

* 23 moms, 37 infants; data births; input plu @@; datalines; 1 1 1 2 2 3 3 3 4 4 4 4 1 1 1 1 1 1 4 4 4 4 2 2 2 2 2 2 3 3 3 1 1 1 1 1 1 ; run;

proc freq data=births; table plu / out=temp; run;

data _null_; set temp end=last; moms + count/plu; if last then put "MOMS: " moms; run;

in the log ...

MOMS: 23

or skip FREQ and just use a data step ...

data _null_; set births end=last; moms + 1/plu; if last then put "MOMS: " moms; run;

or skip FREQ and just use SQL ...

proc sql; select sum(1/plu) as moms from births; quit;

-- Mike Zdeb U@Albany School of Public Health One University Place (Room 119) Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

> Or just form a new variable for the weight: > > data new; > set births; > if plurality=1 then weight=1; > else if plurality > 1 then weight= 1/plurality; > run; > > proc print data=new(obs=20); > var plurality weight; > run; > > proc sql noprint; > create table mothers as > select sum(weight) as number_of_mothers > from new; > quit; > > or if you want it as a macro variable: > %let number_of_mothers=.; > proc sql noprint; > select sum(weight) as number_of_mothers into :number_of_mothers > from new; > quit; > %put &number_of_mothers; > > or if you were breaking it down by something else, then you could use "group by": > > proc sql noprint; > create table mothers_within_hospitals as > select hospital, sum(weight) as number_of_mothers > group by hospital > from new; > quit; > > > -Mary > > --- sraimi@MARKETINGASSOCIATES.COM wrote: > > From: Steven Raimi <sraimi@MARKETINGASSOCIATES.COM> > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Sorry: title is "Counting mothers from babies" > Date: Wed, 16 Jun 2010 08:12:12 -0400 > > On Wed, 16 Jun 2010 04:44:47 +0000, Laughing Beggar > <laughing_beggar@HOTMAIL.COM> wrote: > >>Hi all, >>I'm working with a dataset where the records are births in a >>year - one birth per child born. I need to get counts of mothers - >>obviously one mother could have, say, up to 4 births records (in the >>case of quads). [Lets not worry about mothers who gave birth twice in >>one year - 9-12 months apart.] I can countthe mothers by using PROC FREQ >> on the variable that gives plurality of birth (coded as '1' for >>singletons, '2' for twins, 3 for triplets etc). By this method the >>number of mothers=(frequency count of singletons)+(frequency count of >>twins/2)+(frequency count of triplets/3)+etc. Ive been doing this on my >>calculator from the PROC FREQ output. But I'd love to be able to do this >> in SAS itself. Any ideas? >>Cheers >>L_B >> >>"The beggar laughs in the face of the thief" >> >> >>_________________________________________________________________ >>New, Used, Demo, Dealer or Private? Find it at CarPoint.com.au >>http://clk.atdmt.com/NMN/go/206222968/direct/01/ > > Seems to me you could use a data step to do the summation. Just make the > calculations mothers = 1 / plurality variable. That'll add 1/1 for > singletons, 1/2 for each twin, etc. > > Steve >


Back to: Top of message | Previous page | Main SAS-L page