|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Data conversion from plot level to household level
On Aug 30, 2007, at 4:57 AM, Sridhar Thapa wrote:
I want to construct data at household level from plot level and
individual level. I was thinking to do it manually but it is
highly time consuming because of large data set.
Not only time consuming, but error-prone. Don't do that.
I did not see any command to manage it at household level. Could
anyone give me some ideas how to manage it? I would be indebted
with you. Thanking you in advance.
Data set like this(HH is the identifier for household level)
HH Plotno Crop labour male labour female
01 1 Paddy 30mandays 35
01 2 Maize 20 22
01 3 wheat 12 16
02 1 Paddy 16 28
02 2 maize 15 18
I intend to convert these plot level data as an aggregate household
level data set
Two basic strategies here. The first is to create your aggregate
variables -- all constant within household -- and then drop all but
one observation per household. There are lots of ways to create
aggregate variables depending on your requirements, but -egen- with
the -by()- option offers a lot in this regard, so that would be a
good place to start. One you've created your aggregate variables,
you can use
bys hh: keep if _n==1
to drop all but one observation per household. A safer way would be
first to drop all of the variables except (1) household id, and (2)
your household-level aggregate variables, and then use
duplicates drop
isid hh
which, if it works without error, will verify that you created your
household aggregates so that they are indeed constant within household.
A second strategy is to use -collapse-, which can do all this in one
step. The downside then is that you're limited to the aggregate
statistics that -collapse- provides. However, if those suit your
needs, then this is the more efficient strategy.
-- Phil
*
* 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/