Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: AW: Carry over information on time-invariant covariate to all observations of a household?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: AW: Carry over information on time-invariant covariate to all observations of a household?
Date   Tue, 3 Aug 2010 19:12:01 +0100

In addition to this and other good advice, note the FAQ 

How can I generate a variable relating panel data to a reference panel? 
http://www.stata.com/support/faqs/stat/panelref.html

It may not sound quite what you want, but the main Stata technique
needed for this problem is discussed with examples. 

Nick 
n.j.cox@durham.ac.uk 

Dr. Martin Weiss

Use

*************
bysort HH (X): replace X = X[1]
*************

then!

Jen Zhen

suppose I have a panel with dimensions Household and Year. I have the
time-invariant household characteristic X. Information on it is
currently given for each household in only one of the years, but I
would like to carry over this information to all observations of each
household.

To illustrate, the dataset looks like this:

HH   Year    X
1     1990     5
1     1991     .
1     1992     .
2     1990     .
2     1991     3
2     1992     .
3     1990     .
3     1991     .
3     1992     2

and I would like to fill in the missing values.

Currently my way of doing it is this:
- bysort HH: egen X2 = max(X) -
- replace X = X2 -

However, in a large dataset running this command takes forever, so I
am wondering whether there is a faster way to do this?


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index