I have individual level panel data that includes spells, with a 6 month *follow up* period after each spell as follows:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(id month) byte spell float spell_followup double(base_y followup_y) float followupmonth 52 1 0 . . . . 52 2 0 . . . . 52 3 0 . . . . 52 4 0 . . . . 52 5 0 . . . . 52 6 0 . . . . 52 7 0 . . . . 52 8 0 . . . . 52 9 0 . . . . 52 10 0 . . . . 52 11 0 . . . . 52 12 0 . . . . 52 13 0 . . . . 52 14 0 . . . . 52 15 0 . . . . 52 16 0 . . . . 52 17 1 . . . . 52 18 1 . . . . 52 19 1 . . . . 52 20 1 . 30.35714340209961 . . 52 21 0 1 . 21.25 1 52 22 2 1 . 21.25 2 52 23 2 1 . 21.25 3 52 24 2 1 . 21.25 4 52 25 2 1 . 21.25 5 52 26 2 1 21.25 21.25 6 52 27 0 2 . 0 1 52 28 0 2 . 32.04545593261719 2 52 29 0 2 . 69.54545593261719 3 52 30 0 2 . 75 4 52 31 0 2 . 37.5 5 52 32 0 2 . 0 6 52 33 0 . . . . 52 34 0 . . . . 52 35 0 . . . . 52 36 0 . . . . 52 37 0 . . . . 52 38 0 . . . . 52 39 0 . . . . 52 40 0 . . . . 52 41 0 . . . . 52 42 0 . . . . 52 43 0 . . . . 52 44 0 . . . . 52 45 0 . . . . 52 46 0 . . . . 52 47 0 . . . . 52 48 0 . . . . 52 49 0 . . . . 52 50 0 . . . . 52 51 0 . . . . 52 52 0 . . . . 52 53 0 . . . . 52 54 0 . . . . 52 55 0 . . . . 52 56 0 . . . . 52 57 0 . . . . 52 58 0 . . . . 52 59 0 . . . . 52 60 0 . . . . 52 61 0 . . . . 52 62 0 . . . . 52 63 0 . . . . 52 64 0 . . . . 52 65 0 . . . . 52 66 0 . . . . 52 67 0 . . . . 52 68 0 . . . . 52 69 0 . . . . 52 70 0 . . . . 52 71 0 . . . . 52 72 0 . . . . 52 73 0 . . . . 52 74 0 . . . . 52 75 0 . . . . 52 76 0 . . . . 52 77 0 . . . . 52 78 0 . . . . 52 79 0 . . . . 52 80 0 . . . . 52 81 0 . . . . 52 82 0 . . . . 52 83 0 . . . . 52 84 0 . . . . 52 85 0 . . . . 52 86 3 . . . . 52 87 3 . . . . 52 88 3 . 23.25 . . 52 89 0 3 . 10.576614379882813 1 52 90 0 3 . 5.2016143798828125 2 52 91 0 3 . 0 3 52 92 0 3 . 10 4 52 93 0 3 . 27.375 5 52 94 0 3 . 34.75 6 52 95 0 . . . . 52 96 0 . . . . 52 97 0 . . . . 52 98 0 . . . . 52 99 0 . . . . 52 100 0 . . . . end
In each of the 6 month follow up period, I want to check if the deviation from the base_y is greater than 15/30/40%. The code I was trying to run is:
Code:
tsset id month bysort id spell_followup (followupmonth): gen var15=((l1.base_y-followup_y)/l1.base_y/>.15) if followupmonth==1 bysort id spell_followup (followupmonth): gen var30=((l1.base_y-followup_y)/l1.base_y/>.30) if followupmonth==1 bysort id spell_followup (followupmonth): gen var50=((l1.base_y-followup_y)/l1.base_y/>.50) if followupmonth==1
But I get an error "not sorted".
Code:
. bysort id spell_followup (followupmonth): gen var15=((l1.base_y-followup_y)/l1.ba > se_y/>.15) if followupmonth==1 not sorted r(5); end of do-file r(5);
Sincerely,
Sumedha.
0 Response to "Not sorted"
Post a Comment