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

st: RE: automatic coding

From   "Nick Cox" <>
To   <>
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 


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:

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