Announcement

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

  • Transforming variable

    I have big trouble with my panel dataset. For each of my countries and years, I have multiple variables in different rows.
    For example one of my variable is called government_level. In the same column different levels of government are displayed accordingly.
    For that reason my country and year are not unique as there are seperare rows such as "Austria, 1995, local government, 10" and "Austria, 1995, state government, 6000).

    How can I transform my dataset so that the value of a given year and country is displayed in distinct variables for all levels of governments?

    Thanks!!

  • #2
    Please read the forum FAQ for excellent advice about posting questions that are likely to draw a timely and helpful response. In particular, even the best descriptions of data are no substitute for an actual data example created with the -dataex- command. so. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    In addition, "I have big trouble" does not define your problem. It's just a variant on the equally unhelpful "doesn't work." From your description, I infer that you are concerned about country and year not uniquely identifying observations. But without knowing what you actually want to do with the data, it is impossible to say how you should resolve it. It may be that you need to define the combination of country and government level as the panel. Or perhaps you need to drop all but one level of government for each country. Or perhaps you need to run a multi-level model rather than a panel-data analysis. Or perhaps you don't need to specify the year when you run -xtset- (in which case Stata will not care that country is not a unique identifier) because you don't need any of the specific calculations that are supported by -xtset panelvar timevar-. Which of these is appropriate will depend on your research goals and analysis plans. So you need to explain what you want to ultimately do with this data. Once you make that clear, I'm confident that it will be straightforward to accomplish it and specific advice will be forthcoming.

    Comment

    Working...
    X