Announcement

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

  • help with -expand-

    Dear statalist,

    I have a set of data which spans from 2019 to 2020, for some firms, the data only has 2019 or 2020, but not both years, for those cases, I want to manually create the missing year. I believe -expand- can do so, but I don't know how exactly.

    Some data here
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long firm float year
      1 2020
      2 2019
      2 2020
      4 2020
      9 2019
      9 2020
     11 2019
     12 2019
     16 2020
     17 2020
     20 2020
     21 2020
     25 2020
     26 2019
     27 2019
     27 2020
     28 2019
     28 2020
     29 2019
     31 2019
     34 2019
     34 2020
     35 2019
     35 2020
     36 2019
     36 2020
     39 2019
     39 2020
     40 2019
     42 2020
     45 2020
     49 2020
     50 2019
     50 2020
    For example, for firm 1, it only has 2020 but not 2019, so I want to create year 2019 for this firm; similarly, for firm 4, I want to create year 2019. Any help will be greatly appreciated.

  • #2
    I think that you're probably more interested in fillin than expand.

    Take a look at its helpfile
    Code:
    help fillin
    and see whether that gets you where you want to go.

    Comment


    • #3
      thanks it works well!

      Comment

      Working...
      X