Announcement

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

  • filling missing data per id from cells below.

    Dear Stata Community,

    I am working with long panel data. I have multiple observations per id.

    In my original data set I have had to insert a baseline "observation" row for time 0. However I am struggling to fill "empty" cells with information for the particant id such as gender, longest followup.

    I suppose what I am asking is - is there a way I can fill information for specific variables using the cell information from observation "2" for a specific variable and use it to fill in the currently missing observation "1".

    e.g I would like to carry the gender information for the id into observation "1" which is currently missing.

    I hope this question makes sense.

    Many thanks again for all your help,

    ROshani

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(obsnum observation) int id byte(gender first_op) float longest_fu
     1  1 1 . .  .
     2  2 1 1 1 26
     3  3 1 1 1 26
     4  4 1 1 1 26
     5  5 1 1 1 26
     6  6 1 1 1 26
     7  7 1 1 1 26
     8  8 1 1 1 26
     9  9 1 1 1 26
    10 10 1 1 1 26
    11 11 1 1 1 26
    12 12 1 1 1 26
    13 13 1 1 1 26
    14 14 1 1 1 26
    15 15 1 1 1 26
    16 16 1 1 1 26
    17 17 1 1 1 26
    18 18 1 1 1 26
    19 19 1 1 1 26
    20 20 1 1 1 26
    21 21 1 1 1 26
    22 22 1 1 1 26
    23 23 1 1 1 26
    24  1 2 . .  .
    25  2 2 1 2  3
    26  1 3 . .  .
    27  2 3 1 1 21
    28  3 3 1 1 21
    29  4 3 1 1 21
    30  5 3 1 1 21
    31  6 3 1 1 21
    32  7 3 1 1 21
    33  8 3 1 1 21
    34  9 3 1 1 21
    35 10 3 1 1 21
    36 11 3 1 1 21
    37 12 3 1 1 21
    38 13 3 1 1 21
    39 14 3 1 1 21
    40 15 3 1 1 21
    41  1 4 . .  .
    42  2 4 0 2 22
    43  3 4 0 2 22
    44  4 4 0 2 22
    45  5 4 0 2 22
    46  6 4 0 2 22
    47  7 4 0 2 22
    48  8 4 0 2 22
    49  1 5 . .  .
    end
    label values first_op type_of_op
    label def type_of_op 1 "IRA", modify
    label def type_of_op 2 "RPC", modify
    ------------------ copy up to and including the previous line ------------------

  • #2
    Fortuitously, or otherwise, this question is being asked about once a day at the moment, so the advice please to read Statalist as well as write to it is pertinent. Otherwise https://www.stata.com/support/faqs/d...issing-values/ is one general discussion.

    Comment


    • #3
      Ok thank you.... I managed to find it from a previous code you had provided
      bysort id : replace gender = gender[_n+1] if missing(gender)

      Thanks again for your swift response

      Comment

      Working...
      X