Announcement

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

  • how to generate new panel units

    Hi all,

    I have a panel dataset where I want to generate new panel units and calculate data for them based on the existing ones. To be more precise: my dataset includes country level data (e.g. GDP, employment, etc.) for about 180 countries; it also includes the same variables for selected cities within each country. Summing up the city-level data for each country is always less than the corresponding country aggregate, so what I want to do is to generate new data for each country with the residual values of each variable.

    For example: I have GDP for the U.K. as a whole. I also have GDP for London, Birmingham and Manchester. What I need to do is generate a new panel entry, called let's say UK_other, for which I will then calculate and store the corresponding part of the GDP as: GDP(UK) - GDP(London) - GDP(Birmingham) - GDP(Manchester).

    Any help would be greatly appreciated.

    best,

    Stefanos

  • #2
    Have you ever tried going to an online map site to find driving directions to a specific destination? What would happen if you didn't provide any starting point? That's, in effect, what you have done here. There are many ways this data could be organized, and they would require different code to achieve your goal. You need to show example data here.

    Please use the -dataex- command to do that. If you are running version 15.1 or a fully updated version 14.2, -dataex- 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.

    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X