Announcement

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

  • How to replace dummy by same value of adjacent year for each id observation?

    Hi my data's dummy 'chaebol' has its value only when year = 2004.
    How can I replace the value of chaebol in 1996 by the same value as 2004 for each firmid?

    thank you.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str6 firmid float year double asset byte chaebol
    "000020" 1996   28259495 .
    "000020" 2004   48186088 0
    "000070" 1996  421634354 .
    "000070" 2004  374350110 1
    "000100" 2004  205853387 0
    "000100" 1996  144924321 .
    "000140" 2004 1290148390 1
    "000140" 1996  983906135 .
    "000220" 2004   29482372 0
    "000220" 1996    6159711 .
    "000230" 2004   74269529 0
    "000230" 1996   27699544 .
    "000320" 2004  146142011 0
    "000320" 1996   70410218 .
    "000430" 2004  142973946 0
    "000430" 1996  106637687 .
    "000480" 1996   87579814 .
    "000480" 2004   68576928 0
    "000490" 2004  121681902 0
    "000490" 1996   88517309 .
    "000500" 1996   60492603 .
    "000500" 2004   92325546 1
    "000520" 1996    6364544 .
    "000520" 2004   17982517 0
    "000590" 2004   35330184 0
    "000590" 1996   14533334 .
    "000640" 1996   46398066 .
    "000640" 2004  186631617 0
    "000650" 1996   17102946 .
    "000650" 2004   22448651 0
    "000670" 2004  404231338 1
    "000670" 1996  109286087 .
    "000700" 2004 3292007620 1
    "000700" 1996 1852004833 .
    "000880" 1996  543269083 .
    "000880" 2004  779888412 1
    "000890" 1996   63453223 .
    "000890" 2004   90026913 0
    "000970" 2004   93380640 0
    "000970" 1996   12573848 .
    "000990" 2004  459114340 1
    "000990" 1996   66795516 .
    "001040" 1996  880766514 .
    "001040" 2004  969657971 1
    "001060" 2004   93182953 0
    "001060" 1996   35565684 .
    "001080" 1996   29543083 .
    "001080" 2004   96897684 0
    "001120" 1996  175916675 .
    "001120" 2004  193549685 1
    "001130" 2004  114773996 0
    "001130" 1996   30945961 .
    "001140" 2004   25879110 0
    "001140" 1996   12975089 .
    "001210" 1996   89901905 .
    "001210" 2004  119539694 0
    "001230" 2004 1584426731 1
    "001230" 1996  583272157 .
    "001340" 2004   59340413 0
    "001340" 1996   35424128 .
    "001460" 1996   75982454 .
    "001460" 2004  147393982 0
    "001470" 2004  214133707 0
    "001470" 1996   72399099 .
    "001530" 2004   88432872 0
    "001530" 1996  183814351 .
    "001620" 1996   21019573 .
    "001620" 2004   42860335 0
    "001680" 2004  550244868 0
    "001680" 1996   93694966 .
    "001740" 1996   87533066 .
    "001740" 2004 1770056619 1
    "001790" 2004  167809085 0
    "001790" 1996   86010122 .
    "001820" 1996   14528497 .
    "001820" 2004   15355972 0
    "001880" 1996   23523798 .
    "001880" 2004    7195062 1
    "002020" 2004 1003823716 1
    "002020" 1996  729338774 .
    "002030" 1996  152737683 .
    "002030" 2004  288216881 0
    "002070" 1996   17822714 .
    "002070" 2004   63450207 0
    "002210" 2004   28858778 0
    "002210" 1996   23202529 .
    "002240" 1996   45849936 .
    "002240" 2004  117037787 0
    "002380" 1996  343722055 .
    "002380" 2004 1179028364 1
    "002390" 2004   92473723 0
    "002390" 1996   91011028 .
    "002420" 1996    3607471 .
    "002420" 2004   20439394 0
    "002620" 2004   46438962 0
    "002620" 1996   11734839 .
    "002720" 1996   13431501 .
    "002720" 2004   30693353 0
    "002760" 2004   10444979 0
    "002760" 1996    8135527 .
    end
    Last edited by Chul-Kyoo Jung; 28 Oct 2021, 07:33.

  • #2
    Code:
    bys firmid (year): replace chaebol = chaebol[_n+1] if missing(chaebol)
    Last edited by Øyvind Snilsberg; 28 Oct 2021, 08:15.

    Comment


    • #3
      Thank you so much!

      Comment

      Working...
      X