Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem to create numeric country variable for panel data

    hello eyeryone,

    i merged a few data sets from EuropeanSocial Survey.

    I allready created a numeric country variable:

    generate country_id=.
    replace country_id = 1 if cntry == "BE"
    replace country_id = 2 if cntry == "CH"
    replace country_id = 3 if cntry == "DE"
    replace country_id = 4 if cntry == "DK"
    replace country_id = 5 if cntry == "ES"
    replace country_id = 6 if cntry == "FI"
    replace country_id = 7 if cntry == "FR"
    replace country_id = 8 if cntry == "GB"
    replace country_id = 9 if cntry == "IE"
    replace country_id = 10 if cntry == "NL"
    replace country_id = 11 if cntry == "NO"
    replace country_id = 12 if cntry == "PT"
    replace country_id = 13 if cntry == "SE"

    now i need to declare a time series structure which sorts my cases by wave (Year of Survey) and country. I tried it like this but it did not work:


    sort country_id wave
    by wave: gen time_country_id = _n
    tsset country_id time_country_id

    i hope that someone can help me!

    thanks a lot in advance!!
    Simon

  • #2
    Next time you may want to use encode to make a numeric country variable. Saves a lot of typing
    Code:
    encode cntry, gen(country_id)
    Is your data still in the original structure; that is to say individual level data?
    ESS is not a longitudinal dataset: different people are interviewed each wave.
    Might the problem be that you have several cases per country*wave rather than only one?
    Or did you aggregate data to the country*wave level?

    For the continuation of this discussion it would be helpful, if you say a bit more than 'it did not work' (post the error message Stata returns) and post your code in code format (see FAQ on how to do this)
    Last edited by Evelyn Ersanilli; 19 Aug 2015, 06:00. Reason: Typo in the code

    Comment


    • #3
      thanks for the quick answer.
      In general i want to do a multilevel analysis. I'm using every wave (2004, 2006, 2008. 2010, 2012) of the ESS for 13 different countries. I generated a Gini variable (Income Inequality) for each wave and each country. My dependend Variable is an Index of political partizipation. The first level is the individual level (independed variables political interest, income, age, education,gender). On the second level (makrolevel) i would like to integrate my Gini-Variable for each wave and country.

      Before I merged the datasets i generated a wave variable as well as the gini variable for each Dataset.

      when i started my analysis i was't aware of the country variable being not numeric so i created one, but i don't no how to sort my dataset to use the Gini variable in my multilevel analysis.

      Comment

      Working...
      X