Announcement

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

  • spread one number within a group

    I have a data set looking like this, when fic is not USA, local_markup is missing value. For the missing values, I want to fill them with the value of USA. The local_markup change every year. Please help me. Thanks!
    local_markup fyear fic
    8745.155 2001 USA
    8745.155 2001 USA
    8745.155 2001 USA
    8745.155 2001 USA
    8745.155 2001 USA
    8745.155 2001 USA
    8745.155 2001 USA
    8745.155 2001 USA
    2001 CHE
    8745.155 2001 USA
    2001 CHE
    8745.155 2001 USA
    2001 JPN
    8745.155 2001 USA

  • #2
    Hi Johnny,

    If local markup stays constant for each year for US, you can use this (or a variant which works best for you):

    Code:
    by fyear, sort: egen lm_US = mean(local_markup)
    replace local_markup = lm_US if (fic != "US" & local_markup == .)

    Comment


    • #3
      Originally posted by Ashish Tyagi View Post
      Hi Johnny,

      If local markup stays constant for each year for US, you can use this (or a variant which works best for you):

      Code:
      by fyear, sort: egen lm_US = mean(local_markup)
      replace local_markup = lm_US if (fic != "US" & local_markup == .)
      Thank you Ashish! This solved my problem!

      Comment

      Working...
      X