Bookmark and Share

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: Difference between variables per year


From   Maarten Buis <[email protected]>
To   [email protected]
Subject   Re: st: Difference between variables per year
Date   Wed, 27 Nov 2013 13:44:52 +0100

On Wed, Nov 27, 2013 at 11:22 AM, Maurits Meijers Baumeister  wrote:
>  I am using a data set that shows party positions per election year for multiple countries.  I'm looking to create a variable that shows the difference of the party position of a particular election year with the party position of the previous election year.     Please note that elections in the data set mostly do not happen yearly, although sometimes they might.   Moreover, the election years will be the same for all parties in the same country but will differ per country.     How do I do this?

Say, your dataset contains the variables country, party, year, and
position to identify the country, party, year of the election and the
position of that party in that election. In that case I would type in
Stata:

sort country party year
by country party : gen diff = position - position[_n-1]

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------

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


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