Announcement

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

  • stdescribe command reports time on gap

    I am using Stata 16 to do a survival analysis of data created in a restricted data enclave. I cannot provide you with example data but my question may be more general.

    When I run the stdescribe command on my stset data, it shows that I have a small number of cases with gaps.

    I would like to identify and inspect the records with gaps to understand if this is an error. Is there a way I can identify the ids of the cases with gaps?

    Thank you for your help.

  • #2
    Try this:
    Code:
    by id (_t), sort: gen byte gap = _t0 != _t[_n-1] & _n > 1
    
    levelsof id if gap
    In this code, replace id by the name of the variable that identifies individuals in your data set.

    As no example data was available, this code is untested.

    Comment


    • #3
      The help files provides example data. Following #2:
      Code:
      use https://www.stata-press.com/data/r18/mfail2, clear
      stdescribe
      
      by id (_t), sort: gen byte gap = _t0 != _t[_n-1] & _n > 1
      
      levelsof id if gap ,  separate(,) 
      
      list if inlist(id, `r(levels)') , sepby(id) noobs
      Code:
       +--------------------------------------------------+
        |  id     t   d    t0   _st   _d    _t   _t0   gap |
        |--------------------------------------------------|
        | 145   292   1     0     1    1   292     0     0 |
        | 145   360   0   326     1    0   360   326     1 |
        |--------------------------------------------------|
        | 292   451   1     0     1    1   451     0     0 |
        | 292   717   1   584     1    1   717   584     1 |
        | 292   748   0   717     1    0   748   717     0 |
        |--------------------------------------------------|
        | 466   691   1     0     1    1   691     0     0 |
        | 466   723   0   707     1    0   723   707     1 |
        |--------------------------------------------------|
        | 730   281   1     0     1    1   281     0     0 |
        | 730   527   0   404     1    0   527   404     1 |
        |--------------------------------------------------|
        | 763   472   1     0     1    1   472     0     0 |
        | 763   520   0   496     1    0   520   496     1 |
        |--------------------------------------------------|
        | 890   611   1     0     1    1   611     0     0 |
        | 890   773   1   692     1    1   773   692     1 |
        | 890   824   0   773     1    0   824   773     0 |
        +--------------------------------------------------+

      Comment

      Working...
      X