When I said "no more efficient" I meant "no less efficient".
Nick
[email protected]
Nick Cox
> The Stata manual example somehow evokes
> the cuisine available in College Station, TX,
> modulo MadCows.
>
> Richard Gates has already answered your main
> question. I just to comment on a detail as
> below. Another way to get these variables
> is with a loop:
>
> forval i = 1/6 {
> gen kid`i' = (restaurant == `i') * kids
> }
>
> Another way is by
>
> separate kids, by(restaurant) gen(kid)
> mvencode `r(varlist)', mv(0)
>
> Your code is fine and clear (and, notably,
> going to be no more efficient than either
> of the above). But other ways of doing it
> may be of interest to those who look at
> an example like this and think "Surely
> there is another way to do this!".
>
> Nick
> [email protected]
>
> Matthias Grueninger
>
> > gen kid1=(restaurant==1)*kids
> > gen kid2=(restaurant==2)*kids
> > gen kid3=(restaurant==3)*kids
> > gen kid4=(restaurant==4)*kids
> > gen kid5=(restaurant==5)*kids
> > gen kid6=(restaurant==6)*kids
*
* 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/