st: Re: Problem of using XI

Ji-Tian Sheu wrote:
I have a variable (age) with 5 categories.
I would like to create age-category dummy.
I use the command, -xi-.
However, everytime, I type: xi: i.age
I obtained an error message: unrecognized command: _Iage_ r(199);
However, after that, I type: sum *age*. I can still find that Stata has
created those dummies.
Anyone knows why?
----------------------------------------------------------------------------
When you use -xi- in combination with another command, for example,
with -regress-, you must use the : (colon character).
xi: regress y i.age
But when you use -xi- alone with just the variable, then you must not use
the colon character.
xi i.age <-- notice that there is no colon in this usage of -xi-
regress y _I*
If you violate the rule, for example,
xi: i.age
then Stata will actually do the dummy variable creation, but it will also
complain about the violation of syntax rules. With the colon character,
Stata expects the immediately following text to be another command, such
as -regress-. The complaint (error message) is that _Iage_ is not the name
of any command that Stata can find.
Although it might appear tha Stata correctly created the dummy variables
despite the violation of syntax rules in this example (with the age
variable), be careful: because you violate the syntax rules for -xi-, I
would not trust that Stata properly does the dummy variable creation
correctly in every future situation.
So it is better to use the colon character only when -xi- is used on
conjuction with another command (like -regress-) and not use the colon
character when -xi- is used alone with just a variable in order to create
dummy variables for use later.
Joseph Coveney
*
* 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/