Announcement

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

  • Dataset with multiple Years for each ID Command: xtset ID Year Error: repeated time values within panel r(451);

    Dear Forum,

    We are setting up a model for explaining the number of Private Public Partnerships. We are in a very early stage of doing this. The current problem is to set up an appropriate data set that helps us analyze the case.

    We are using the data from here:
    http://www.worldbank.org/en/topic/pu...tepartnerships

    Using panel data might be beneficial since the data gives enough information for that.
    However, Panel data requires that observations in time cannot appear more than once per ID.
    In the data several investments are undertaken in a country per year, which is a problem for xtset.

    Since we do not want to lose the information given by multiple PPPs undertaken within a country in one year, transforming the data for only
    one investment per year does not seem to be a good approach.

    Can someone give us please an advise for dealing with this issue?

    Another issue we face is, that the data set does not give the GDP, but we want to account for it in the mode. Therefore we need to include it from a different data set. Depending on how we deal with the first issues bringing in the GDP would follow a different approach. If we leave the data set like it is and just set up xtset for the ID, how would we include the GDP data smoothly from a dataset that gives a figure per year?

    Any guidance is much appreciated.

    A Screenshot of the current data is here:


    Best,

    Michél
    Attached Files

  • #2
    Michél:
    I would take a look at -collapse-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo:
      Thank you very much for your quick response. We collapsed using these commands:
      gen one=1
      collapse (sum)one Total_Investment Physical_Assets Fees_To_Government Capacity Total_Debt_Funding IDAdummy PDdummy Incomegroup IncomeLevel , by(IDcountry)
      This makes the variable one being the overal PPPs per country in the collapsed data. The other variables will become the overall sum for each country.
      We transformed the dummies appropriately and now we have a few variables we might be able to work with.
      So far so good.

      However, this way we are losing the year variable and we cannot account for GDP anymore, since the PPPs in each country are now an overall sum of all PPPs in history.



      Comment


      • #4
        Why not

        Code:
        collapse <whatever>, by(IDCountry year)

        Comment


        • #5
          Michèl:
          I meant something along Nick's line.
          Unfortunately, I was caught in a call during my reply and could not elaborate on my minimal suggestion.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Thank you Nick and Carlo!

            It works now.

            collapse (sum)one Total_Investment Physical_Assets Fees_To_Government Capacity Total_Debt_Funding IDAdummy PDdummy Incomegroup IncomeLevel , by(IDcountry InvestmentYear)
            rename one PPP

            xtset IDcountry InvestmentYear
            . xtset IDcountry InvestmentYear
            panel variable: IDcountry (unbalanced)
            time variable: InvestmentY~r, 1992 to 2016, but with gaps
            delta: 1 unit

            Now I am able to prepare and do some merges.


            Best,

            Michél

            Comment

            Working...
            X