Announcement

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

  • Episode Creation

    I have to write a code which can make episodes on WHO diarrhea definition
    need serial of episode per id in ep_sr

    studyid vdt visitid fup dia dia_ep ep_sr
    5 10-Jun-16 10 1
    5 11-Jun-16 11 2
    5 12-Jun-16 12 3
    5 13-Jun-16 13 4
    5 14-Jun-16 14 5
    5 15-Jun-16 15 6
    5 16-Jun-16 16 7
    5 17-Jun-16 23 8
    5 18-Jun-16 24 9
    5 19-Jun-16 25 10
    5 20-Jun-16 26 11
    5 21-Jun-16 27 12
    5 22-Jun-16 28 13
    5 23-Jun-16 29 14
    5 24-Jun-16 1 15
    5 25-Jun-16 1 16
    5 26-Jun-16 1 17
    5 27-Jun-16 2 18
    5 28-Jun-16 3 19
    5 29-Jun-16 4 20
    5 30-Jun-16 1 21
    5 2-Jul-16 2 22
    5 3-Jul-16 3 23
    5 4-Jul-16 4 24
    5 5-Jul-16 5 25
    5 6-Jul-16 6 26
    5 7-Jul-16 7 27
    5 8-Jul-16 8 28
    5 9-Jul-16 9 29
    5 10-Jul-16 10 30
    5 11-Jul-16 11 31
    5 12-Jul-16 12 32
    5 13-Jul-16 13 33
    5 14-Jul-16 14 34
    5 15-Jul-16 15 35
    5 16-Jul-16 16 36
    5 17-Jul-16 17 37
    5 18-Jul-16 18 38
    5 19-Jul-16 19 39
    5 20-Jul-16 20 40
    5 21-Jul-16 21 41
    5 22-Jul-16 22 42
    5 23-Jul-16 23 43
    5 24-Jul-16 24 44
    5 25-Jul-16 25 45
    5 26-Jul-16 26 46
    5 27-Jul-16 27 47
    5 28-Jul-16 28 48
    5 29-Jul-16 29 49
    5 30-Jul-16 5 50
    5 1-Aug-16 1 51
    5 2-Aug-16 2 52
    5 3-Aug-16 3 53
    5 4-Aug-16 4 54
    5 5-Aug-16 5 55
    5 6-Aug-16 7 56
    5 7-Aug-16 8 57
    5 8-Aug-16 9 58
    5 9-Aug-16 2 59
    5 10-Aug-16 3 60
    5 11-Aug-16 4 61
    5 12-Aug-16 5 62
    5 13-Aug-16 6 63
    5 14-Aug-16 7 64
    5 15-Aug-16 8 65
    5 16-Aug-16 1 66
    5 17-Aug-16 1 67
    5 18-Aug-16 1 68
    5 19-Aug-16 2 69
    5 20-Aug-16 2 70
    5 21-Aug-16 3 71
    5 22-Aug-16 4 72 1 0
    5 23-Aug-16 5 73
    5 24-Aug-16 6 74
    5 25-Aug-16 7 75
    5 26-Aug-16 8 76
    5 27-Aug-16 9 77
    5 28-Aug-16 10 78
    5 29-Aug-16 11 79 1 0
    5 1-Sep-16 9 80
    5 2-Sep-16 10 81
    5 3-Sep-16 11 82
    5 4-Sep-16 12 83
    5 5-Sep-16 13 84
    5 6-Sep-16 14 85
    5 7-Sep-16 15 86
    5 8-Sep-16 1 87
    5 9-Sep-16 2 88
    5 10-Sep-16 16 89
    5 11-Sep-16 17 90
    5 12-Sep-16 18 91
    5 13-Sep-16 19 92
    5 14-Sep-16 20 93
    5 15-Sep-16 21 94
    5 16-Sep-16 22 95
    5 17-Sep-16 23 96
    5 18-Sep-16 24 97
    5 19-Sep-16 25 98
    5 20-Sep-16 26 99
    5 21-Sep-16 27 100
    5 22-Sep-16 28 101
    5 23-Sep-16 29 102
    5 24-Sep-16 30 103
    5 25-Sep-16 31 104
    5 26-Sep-16 32 105
    5 27-Sep-16 3 106
    5 28-Sep-16 4 107
    5 29-Sep-16 5 108
    5 30-Sep-16 33 109
    5 1-Oct-16 34 110
    5 2-Oct-16 35 111
    5 3-Oct-16 36 112
    5 4-Oct-16 37 113
    5 5-Oct-16 38 114
    5 6-Oct-16 39 115
    5 7-Oct-16 40 116
    5 8-Oct-16 41 117
    5 9-Oct-16 42 118
    5 10-Oct-16 43 119
    5 11-Oct-16 44 120
    5 12-Oct-16 45 121
    5 13-Oct-16 46 122
    5 14-Oct-16 47 123
    5 15-Oct-16 48 124
    5 16-Oct-16 49 125
    5 17-Oct-16 50 126
    5 18-Oct-16 6 127
    5 19-Oct-16 7 128
    5 20-Oct-16 51 129
    5 21-Oct-16 52 130
    5 22-Oct-16 53 131
    5 23-Oct-16 54 132
    5 24-Oct-16 55 133
    5 25-Oct-16 56 134
    5 26-Oct-16 57 135
    5 27-Oct-16 58 136
    5 28-Oct-16 59 137
    5 29-Oct-16 60 138
    5 30-Oct-16 61 139
    5 31-Oct-16 62 140
    5 1-Nov-16 63 141
    5 3-Nov-16 64 142
    5 4-Nov-16 65 143
    5 5-Nov-16 66 144
    5 6-Nov-16 67 145
    5 7-Nov-16 68 146
    5 8-Nov-16 69 147
    5 9-Nov-16 70 148
    5 10-Nov-16 71 149
    5 11-Nov-16 72 150
    5 12-Nov-16 73 151
    5 13-Nov-16 74 152
    5 14-Nov-16 75 153
    5 15-Nov-16 76 154
    5 16-Nov-16 77 155
    5 17-Nov-16 78 156
    5 18-Nov-16 79 157
    5 20-Nov-16 80 158
    5 21-Nov-16 81 159
    5 22-Nov-16 82 160
    5 23-Nov-16 83 161
    5 24-Nov-16 84 162
    5 25-Nov-16 85 163
    5 26-Nov-16 86 164
    5 27-Nov-16 8 165
    5 28-Nov-16 9 166
    5 29-Nov-16 87 167
    5 30-Nov-16 88 168
    5 1-Dec-16 89 169
    5 2-Dec-16 90 170
    5 3-Dec-16 91 171
    5 4-Dec-16 92 172
    5 5-Dec-16 93 173
    5 6-Dec-16 94 174
    5 7-Dec-16 95 175
    5 8-Dec-16 96 176
    5 9-Dec-16 97 177
    5 10-Dec-16 98 178
    5 11-Dec-16 99 179
    5 12-Dec-16 100 180
    5 13-Dec-16 101 181
    5 14-Dec-16 102 182
    5 15-Dec-16 103 183
    5 16-Dec-16 104 184
    5 17-Dec-16 10 185
    5 18-Dec-16 11 186
    5 19-Dec-16 12 187
    5 20-Dec-16 105 188
    5 21-Dec-16 106 189
    5 22-Dec-16 107 190
    5 23-Dec-16 108 191 1 1 1
    5 24-Dec-16 109 192 1 1 1

  • #2
    Please define what marks the beginning, and what marks the ending, of an "episode." Please explain why the diarrhea on 22-Aug and 29-Aug do not constitute "episodes."

    In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 15.1 or a fully updated version 14.2, it is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment


    • #3
      Thank you so much.I will follow your suggestions. I actually copy it from excel and made this output manually. There is no end point. i have 500 enrollments with daily follow ups. some can grow up day 0 to day 1825 days. But any one can exit any time.
      So the idea is a code should pick 1st and followed below definition give episodes serial , then next Id

      Diarrhea episode
      A diarrhoeal episode will be defined as a minimum of 2 days with diarrhoeal followed by at least 2 diarrhoeal-free days.

      Comment


      • #4
        At least in your data example, this definition of diarrheal episode cannot be properly applied because there are gaps in the dates. ID 5 skips from June 30 to July 2 and we might miss an episode in there that is not reported. Worse yet, we also skip from August 29 to September 1, and September 1 is a diarrhea day, so it is crucial to know if the skipped day was also a diarrhea day.

        Added: And in your example, you mark the last two days as a diarrhea spell, but in fact you do not have any diarrhea free days (or any days at all) after that! So your example has no diarrhea spells. Please pick a better example and re-post.

        I actually copy it from excel and made this output manually.
        If you haven't actually imported your data into Stata, it is premature to ask for Stata code to manage or analyze it. If you have it in Stata, then you should use the Stata data set, and the -dataex- command to show your example.
        Last edited by Clyde Schechter; 10 May 2018, 13:16.

        Comment

        Working...
        X