Announcement

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

  • Has name only for the first obs. of a chunk. Any way to replicate the names for the rest of the obs. in the same chunk?

    Hi Stata users,

    sorry for the ambiguous title as I was not sure how to name.
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str14 A str48 B str4 C str9 D
    "14511"    "City A"            "2008" "51876428"
    ""         ""                           "2009" "57875793"
    ""         ""                           "2010" "70780936"
    ""         ""                           "2011" "40735295"
    ""         ""                           "2012" "28646830"
    ""         ""                           "2013" "39921705"
    ""         ""                           "2014" "81359869"
    ""         ""                           "2015" "61414445"
    ""         ""                           "2016" "51219016"
    "14511000" "Chemnitz, Stadt"            "2008" "51876428"
    ""         ""                           "2009" "57875793"
    ""         ""                           "2010" "70780936"
    ""         ""                           "2011" "40735295"
    ""         ""                           "2012" "28646830"
    ""         ""                           "2013" "39921705"
    ""         ""                           "2014" "81359869"
    ""         ""                           "2015" "61414445"
    ""         ""                           "2016" "51219016"
    "14521"    "Erzgebirgskreis"            "2008" "116761269"
    ""         ""                           "2009" "121993743"
    ""         ""                           "2010" "142262336"
    ""         ""                           "2011" "106388111"
    ""         ""                           "2012" "119621410"
    ""         ""                           "2013" "91613363"
    ""         ""                           "2014" "97265208"
    ""         ""                           "2015" "73273816"
    ""         ""                           "2016" "84928818"
    "14521010" "City B"                   "2008" "592819"   
    ""         ""                           "2009" "467577"   
    ""         ""                           "2010" "399533"   
    ""         ""                           "2011" "1138856"  
    ""         ""                           "2012" "883090"   
    ""         ""                           "2013" "886560"   
    ""         ""                           "2014" "1459176"  
    ""         ""                           "2015" "531598"   
    ""         ""                           "2016" "182032"
    I want to import an excel file that looks like this. When I import it, the nams and codes are empty except for the first observation in each group.
    Do you know any way to fill in these as the same as the first observation?


  • #2
    Is this doing it?
    Code:
    . replace A = A[_n-1] if missing(A)
    (32 real changes made)

    Comment


    • #3
      Hi Joro,

      thank you so much! It works!!

      Best,
      Ed

      Comment


      • #4
        https://www.stata.com/support/faqs/d...issing-values/ is a write-up of Joro Kolev's technique.

        Comment

        Working...
        X