Announcement

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

  • Condensing observations

    I have population data for a country per year. Currently, there is three year-observations per country which I would like to condense so that there is one row per country-year. Here is how the data looks like:
    Year Country Name population level 1 population level 2 population level 3
    1989 Italy 1117967 . .
    1989 Italy . 1922792 .
    1989 Italy . . 155041
    As I have many countries in the dataset, I would like to automatize the process so I can get something like:
    Year Country Name population level 1 population level 2 population level 3
    1989 Italy 1117967 1922792 155041
    1990 Italy xxx yyy zzz
    1991 Italy mmm nnn ddd
    I was approaching the problem from removing duplicates to "bysort-ing" and dropping observations perspective, but I cannot get it properly working.
    Was having trouble tracking down specific guidance for this, so thank you so in advance for the help offered.

  • #2
    You need something like

    Code:
    collapse (firstnm) ..., by(country year)
    where the ... depend on variable names we can't see and any other details.

    firstnm as a search term may catch other mentions.

    Comment


    • #3
      Dear,
      Thank you! Perfect solution.

      Comment

      Working...
      X