Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Creating Dummys from a variable with 5 categories

From   daniel klein <>
Subject   Re: st: Creating Dummys from a variable with 5 categories
Date   Sun, 2 Dec 2012 11:41:44 +0100


reading this once again, I might have got you wrong. Do you want _one_
dummy (indicator) variable, indication anything else but "flat fee"?
If so, read on. If not, ignore the rest of this message.

In this case you (probably) want the indicator to be 1 if a person
checks anything but "flat fee", 0 otherwise, making "flat fee" your
reference in follwoing analysis. The code you gave is basically ok
(besides not handling missing values, see below), it merely reverses
this coding. It assigns 1 if the answer is "flat fee", 0 otherwise.
Note that the coding order (i.e. 1 for "flat fee" vs. 0 for "flat
fee") does not really matter, as it merely changes the sign of an
estimated coefficient. But if want "flat fee" to be the reference,
code instead

g byte not_flatfee = (YYYY != 1) if !mi(YYYY)

Note the -if- qualifier, to make sure missing values in YYYY are also
missing values in the created dummy variable. Omitting the -if-
qualifier results in missing values in YYYY being coded 1 in the
indicator variable.

I am not sure what you mean by your code not incorporating  "all the
variables" -- there is only one variable (i.e. YYYY) with 5 levels
(i.e. distinct values).


I have a variable with 5 answers and need to make a dummy variable from it


If I want to create a dummy variable that uses Flat Fee as a reference point

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index