[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: RE: RE: series of value labels and collapse
> For those
> interested the alternative to my previous posting is:
> u ctypes, clear
> drop *_*
> egen cmiss = rmiss(c?)
> gen cpresent = 3 - cmiss
> tab cpresent cmixtures
> drop cmixtures-cpresent
> reshape long c, i(id plot)
> drop if area == .
> drop if id == .
> drop if c == .
> bysort id plot : gen Area = area / _N
> tabstat Area, by(c) s(sum)
What's the moral here? Adama had a structure of
* several farmers
* each farmer can have several plots (i.e. one or more)
* each plot can have several crop types (i.e. one or more)
The interest lies in various reductions
of the data. The most flexible structure
is a "long long" structure, e.g.
farmer plot crop
1 1 1
1 1 2
1 2 42
1 3 77
2 1 11
2 1 12
2 2 42
after which the key tool is -by:-.
Looping over the possibilities with -forval- or
-foreach- is then unnecessary and we have
an example of "programming without programming".
-reshape-s to "long long" are also
* For searches and help try: