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

Re: st: the xi: command --- an uglier hack

From   Mark Schaffer <[email protected]>
To   [email protected]
Subject   Re: st: the xi: command --- an uglier hack
Date   Fri, 05 Jul 2002 16:16:40 +0100 (BST)

On Fri, 05 Jul 2002 10:44:50 -0400 (EDT), Michael Ash 
<[email protected]> wrote:

> > I am using the xi: command to construct dummy variables
> > from categorical variables. My problem is that I would
> > like the xi-command to not remove one of the dummies...
> > I just want to add that I've run into this problem too,
> > and I too consider it a (rare) limitation.  More than
> > once I've wanted to run a regression with explicit
> > dummies for each category in combination with the
> > -nocons- option, and without an ugly hack not worth
> > repeating here (Uli's suggestion is *much* nicer) it
> > isn't possible with -xi-'s dummies.
> I agree that the "tab, gen()" solution is much nicer, but
> here is the "ugly" hack.  The following command "xa" works
> exactly like "xi" except it does not omit any category.  I
> believe that it does not interfere with the normal operation
> of xi. Comments welcome.
> -Michael Ash
> ------xa.ado-----CUT BELOW THIS LINE-------
> *! version 1.1.0   10/19/94
> program define xa
> 	version 4.0


Actually, the ugly hack I had in mind was uglier but shorter.

Say the categorical variable is called -industry-, which in the 
dataset takes either positive integer values or is missing.

I would create an additional observation in the data that has a 
missing value for every variable except -industry-.  The variable
-industry- takes the value 0 for this observation alone.

I would then use the command

char industry[omit] 0

so that this observation is the benchmark for the dummies created by

I never found any need to drop this phantom observation, though of 
course this could be done after the -xi- command creates the dummies.

Well, I *did* say it was an ugly hack.  It works, though.


Prof. Mark Schaffer
Director, CERT
Department of Economics, School of Management
Heriot-Watt University, Edinburgh EH14 4AS
tel +44-131-451-3494 / fax +44-131-451-3008
email: [email protected]


This e-mail and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to
whom it is addressed.  If you are not the intended recipient
you are prohibited from using any of the information contained
in this e-mail.  In such a case, please destroy all copies in
your possession and notify the sender by reply e-mail.  Heriot
Watt University does not accept liability or responsibility
for changes made to this e-mail after it was sent, or for
viruses transmitted through this e-mail.  Opinions, comments,
conclusions and other information in this e-mail that do not
relate to the official business of Heriot Watt University are
not endorsed by it.
*   For searches and help try:

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