|
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
|