Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: automatic coding


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: automatic coding
Date   Tue, 23 Mar 2004 22:00:28 -0000

. egen group = group(varlist)

maps varlist to integers 1 up 

. tab group, gen(group) 

produces as many dummies as there 
are groups. 

. contract varlist, zero

produces a reduced dataset in which 
every cross-combination (including 
empty cells) appears once, with its 
frequency. 

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

Patrick Sturgis
 
> I would like to be able to produce a variable, or set of 
> dummy variables
> whose values represent every cell of a multi-way table. E.g. if I have
> sex*class*educational level, I would automatically obtain a 
> variable (or
> series of dummies) with values corresponding to every 
> possible combination
> of values on these three variables. Is this possible in stata? Thanks 

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index