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

st: Recoding Question


From   "Geoffrey D. Peterson" <petersgd@uwec.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   st: Recoding Question
Date   Mon, 25 Apr 2005 08:23:07 -0500

Greetings all--
I am struggling to generate a new variable that SEEMS like it should be easy
but has been driving me nuts.

I am working with data that looks like the following:
Country     Year        Democracy Score     Rev?
1                   1999            8                           0
1                   2000            8                           1
1                   2001            2                           0
1                   2002            2                           0
1                   2003            2                           0
1                   2004            2                           0
2                   1999            6                           0
2                   2000            6                           0
2                   2001            6                           1
2                   2002            9                           0
2                   2003            9                           1
2                   2004            2                           0

What I am trying to do is find a way to generate a variable that will code
as "1" for before the first revolution, "0" during ANY revolution, and code
the sequence of the revolution. For example, I would want the data above to
look like this:
       
Country     Year        Democracy Score     Rev?    Code
1                   1999            8                           0          1
1                   2000            8                           1          0
1                   2001            2                           0          2
1                   2002            2                           0          2
1                   2003            2                           0          2
1                   2004            2                           0          2
2                   1999            6                           0          1
2                   2000            6                           0          1
2                   2001            6                           1          0
2                   2002            9                           0          2
2                   2003            9                           1          0
2                   2004            2                           0          3

The goal is to be able to compare the distributions for the democracy scores
before and after the various revolutions. Is there a simple way to do this?

*
*   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/



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