Print

Print


Hi Lex,
In addition to Richards suggestion, assuming your data is in long format, and the possibility that a mother can have >1 child where all or some of them meet your counting criteria, you may consider using the conditional 'cond' statement in conjunction with the functions _n or _N as appropriate.
All the best.
Phillip. 

    On Sunday, 8 July 2018, 18:38:29 BST, Richard Goldstein <[log in to unmask]> wrote:  
 
 first, note that Stata questions are best answered on stateliest.org

second, your data setup is not completely clear to me but I think the following will do what you want:

egen wtmax=max(wt), by(idmom)
gen byte count=wtmax<1.8

this will make count=0 if wtmax>=1.8 and count=1 if wtmax<1.8

Rich

-----Original Message-----
>From: Alexander Manu <[log in to unmask]>
>Sent: Jul 8, 2018 1:19 PM
>To: [log in to unmask]
>Subject: Stata help needed
>
>Dear Allstaters,
>
>I really need help with a Stata command.
>
>I have dataset with a subject identifier, say a mother (RRXX in table). They have just had babies.  Some mothers had singletons whilst some had twins or triplets.  I want to count all mothers who had babies whose birthweight were all less than 1.8kg.  If a mother  has a singleton and the bwt is less than 1.8kg, she will be counted but if she had twins or triplets and one or two had bwt>1.8, she will not be counted. That is to say, all the children she had should be <1.8kg in weight for her to qualify.  This table might help clarify:
>
>idmom
>wt
>RR01
>2.1
>RR01
>2
>RR01
>1.2
>RR02
>2.1
>RR02
>2
>RR03
>3.5
>RR03
>3.4
>RR04
>2.1
>RR05
>2.1
>RR06
>2.3
>RR07
>1.7
>RR08
>1.8
>RR08
>1.1
>RR09
>3.7
>RR10
>2.4
>RR10
>2.3
>
>
>Any help will be welcome.
>
>Lex.
>
>
>You may leave the list at any time by sending the command
>
>SIGNOFF allstat
>
>to [log in to unmask], leaving the subject line blank.

You may leave the list at any time by sending the command

SIGNOFF allstat

to [log in to unmask], leaving the subject line blank.
  

You may leave the list at any time by sending the command

SIGNOFF allstat

to [log in to unmask], leaving the subject line blank.