Announcement

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

  • Make panel data strongly balanced

    Hello everyone,

    I have downloaded Faostat data on price (with more than 120,000 records) and crop quantity (with more than 95,000 records). I used append to set a panel data over the last 20 years. My goal is to have a strongly balanced dataset for the crops variable.
    I declare the dataset as panel (with xtset id yearcode), but an error is shown ("repeated time values within the panel"). Therefore, it was impossible to use spbalance to Make panel data strongly balanced.

    I hope someone can help, please.

    Best,
    Ellebi

  • #2
    If you want to apply any command that depends on

    Code:
    xtset id yearcode
    working, then you need at most one observation for each combination of id and yearcode.

    There are two extreme scenarios.

    1. You think that should be true of your data, in which case -- see also https://www.stata.com/support/faqs/d...d-time-values/ --- you should start with

    Code:
    duplicates report id yearcode
    2. You known that can't be true, as (for example) it is common to have multiple observations in a given year for a given identifier. In this case, you could just

    Code:
    xtset id
    which stil allows many analyses -- or you need to
    Code:
    collapse ... , by(id yearcode).
    where the ellipsis ... has to be filled in with details.
    Last edited by Nick Cox; 05 Feb 2022, 07:35.

    Comment


    • #3
      Hello Nick,

      Very thank you for the valuable help and prompt reply!

      Best,
      Luigino

      Comment

      Working...
      X