Ronnie Babigumira
> > Happy new year (hope its not too late for this). I have
> some household data
> > with a number of variables indicating whether or not a
> household carried
> out
> > a given practice (cropre00 mulch00 grman00). An example
> is given below (1
> if
> > pursued, 0 otherwise)
> >
> > houscode cropre00 mulch00 grman00
> > 12110001 0 0 0
> > 12110002 0 0 0
> > 12110003 1 0 0
> > 12401001 1 0 0
> > 12401002 0 0 0
> > 12401003 0 0 0
> > 12403001 0 0 0
> > 12403002 0 0 0
> > 12403003 1 0 0
> > 14110021 0 0 0
> >
> > I want to generate new variables
> > 1. npracts, which is the number of practices a household
> carried out
> > 2. A number of dummies eg
> >
> > oneprac "Household pursued atleast one practice"
> > twoprac "Household pursued atleast two practice"
> >
Danielle H. Ferry
>
> Use "egen" w/ the "sum" option.
>
Not quite. Ronnie first needs the -rsum()- function
of -egen-:
egen npracts = rsum(*00)
Any number of dummies then follow from
forval i = 1/<whatever> {
gen byte prac`i' = npracts >= `i' & npracts < .
}
The naming scheme oneprac, twoprac, ... will be
more difficult downstream than one like that here.
Nick
[email protected]
*
* 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/