Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: programming in Stata


From   Antoine Terracol <Antoine.Terracol@univ-paris1.fr>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: programming in Stata
Date   Thu, 15 Mar 2007 11:26:54 +0100

. bysort mother_number (nDate) ; gen newvar=GA[_n-1]

Ali Khashan wrote:
Dear all

I have a large dataset similar to this:


mother_number         child_number  GA     nDate            suggested var
1234567891            23456789      35     21 Feb 1975       .
1234567891            23456781      37     30 May 1978       35
1234567891            23456782      40     04 Oct 1982       37
1234567892            56789012      37     17 Mar 1976
1234567893            56489023      40     23 Sep 1985
1234567894            34567891      40     19 Nov 1977
1234567894            45567890      42     13 May 1979

From mother_number you can see that some women have more than one child (they
have the same identification number). GA is gestational age and nDate is date
of birth of the child. I need to generate another variable which indicates
gestational age of the previuos child. For example the first three lines are of
the same mother who gave birth to three children, the new variable would be
missing for child one (since it was the first child), 35 for child two and 37
for thild three.
Could anyone help me to solve this problem. Your help is highly appreciated.

Many Thanks
Ali

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


--
Ce message a ete verifie par MailScanner
pour des virus ou des polluriels et rien de
suspect n'a ete trouve.

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index