I have a problem working on STATA, so I'd like to ask for advice.
I'd like to get a ratio of "." between the first row with starting 1 and the last row with ending 1 in target column.
Take Dataset as an example.
For A0007146, the first row where 1 starts is row 3, and the last row where 1 end is row 7. Then, there is only one "." between row 3 and row 7. So 1/5 is what I want.
For A0027040, the first row where 1 starts is row 9, and the last row where 1 end is row 12. Then, there are two "." between row 9 and row 12. So 2/4 is what I want.
I want to finally get the average of the ratio. I'd like to get ((1/5)+(2/4))/2 in this Dataset.
Any advice is fine.
Thank you
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str8 id float(target day) "A0007146" 0 18232 "A0007146" . 18233 "A0007146" 1 18234 "A0007146" 0 18235 "A0007146" . 18236 "A0007146" 1 18263 "A0007146" 1 18264 "A0027040" . 18265 "A0027040" 1 18266 "A0027040" . 18294 "A0027040" . 18295 "A0027040" 1 18296 "A0027040" 0 18296 end format %td day
0 Response to Find ratio of "." in column
Post a Comment