Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Creating Dummys from a variable with 5 categories
From
"JVerkuilen (Gmail)" <[email protected]>
To
[email protected]
Subject
Re: st: Creating Dummys from a variable with 5 categories
Date
Sun, 2 Dec 2012 10:53:21 -0500
Your question isn't quite specified to be answerable but here's a
quick way to make a dummy variable that has value 1 for flat fee and 0
for any other value of myvar:
generate flatfee = 1
replace flatfee = 0 if myvar != 1
What this syntax does is (a) make a variable flatfee that has 1
everywhere and (b) change all values for which myvar does not indicate
a flat fee to 0. You could also
generate flatfee = 0
replace flatfee = 1 if myvar = 1
which is the opposite process, as it changes the 0s to 1s where flat
fee is applicable. This seems more natural than coding flat fee the 0
and all other methods 1, but if you want the other way around
generate nonflatfee = 1 - flatfee
Try these and then check your work by
tabulate flatfee myvar
which is always a good idea whenever you're recoding variables. You
should see a 2x5 table that has the counts all in the right place.
On Sun, Dec 2, 2012 at 3:27 AM, Sharon Brody <[email protected]> wrote:
> Hi
>
> I have a variable with 5 answers and need to make a dummy variable from it
>
> The question asked - How are you charged for your waste:
> 1. Flat Fee
> 2. Weight or Volume
> 3. Frequency
> 4. Not Charged
> 5. Dont Know
>
> If I want to create a dummy variable that uses Flat Fee as a reference point
>
> 1. How do I create a dummy (I have tried the basic way - gen XXXX =1 replace XXXX=0 if YYYY=>2) but I believe this is incorrect as it doesnt incorporate all the variables.
>
> 2. How do I get Stata 12 to use "Flat Fee" as the reference base point
>
> I am a beginner to statistics so please use simple terminology. Thank You
>
> Sharon
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
--
JVVerkuilen, PhD
[email protected]
"Thus the typical citizen drops down to a lower level of mental
performance as soon as he enters the political field. He argues and
analyzes in a way which he would readily recognize as infantile within
the sphere of his real interests. He becomes a primitive again. His
thinking becomes associative and affective." ---Joseph A. Schumpeter,
Capitalism, Socialism and Democracy, 1950, p. 262.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/