Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Carry forward


From   Tina Hernandez-Boussard <boussard@stanford.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Carry forward
Date   Thu, 3 Oct 2013 21:21:03 -0700

Hi All,

I am having some problems with carryforward and I wanted to see if =
anyone else knows of any problems with this command.

I have a panel dataset that I have created and I want to use the =
carryforward command to fill in missing values. =20

. tsset id enroll

      panel variable:  id (unbalanced)

       time variable:  enroll, 1 to 3, but with gaps

               delta:  1 unit

. tsfill,full

. replace nvisits_year =3D 0 if nvisits_year =3D=3D .

(1517200 real changes made)

. **fill in missing data**

. bysort id: carryforward age, gen(age_1)

age_1:  (1517200 real changes made)


. bysort id: carryforward pay, gen (pay_cf)

pay_cf:  (1516900 real changes made)


. replace age_1 =3D age_1 + 1 if age=3D=3D.

(1517200 real changes made)



I have reloaded the raw data files and ran my exact same do file, =
however I get different results every time I run the code:


. tsset id enroll

      panel variable:  id (unbalanced)

       time variable:  enroll, 1 to 3, but with gaps

               delta:  1 unit

. tsfill,full

. replace nvisits_year =3D 0 if nvisits_year =3D=3D .

(1517200 real changes made)

. **fill in missing data**

. bysort id: carryforward age, gen(age_1)

age_1:  (1517200 real changes made)

. bysort id: carryforward pay, gen (pay_cf)

pay_cf:  (1516901 real changes made)

. replace age_1 =3D age_1 + 1 if age=3D=3D.

(1517200 real changes made)

=20
And the third time I run the code:

. bysort id: carryforward pay, gen (pay_cf)
pay_cf:  (1516894 real changes made)


Any help on what might be happening to the datafile and why the changes =
are not the same each time I run the code?

Thanks

Tina
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index