Announcement

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

  • copying a date within group

    I have a dataset with ID and grouping variable (treatment type), within grouping variable is a date (stopping date) but in some rows missing (every row is a doctor`s visit), how to copy this date to all rows if available within grouping variable and ID so that for each row I know the stopping date of this certain treatment?
    I have tried mipolate and
    bysort ID grouping_variable: replace stop_date = stop_date[_n-1] if missing(stop_date) But nothing

  • #2
    Code:
    by id grouping_variable (stop_date), sort: replace stop_date = stop_date[1]
    Note: Assumes stop_date is a numeric variable. This will not work if it is a string variable. In that case, replace [1] with [_N].

    Comment

    Working...
    X