I have a data set that has a variable "Injury" is an indicator of whether an individual sustained an injury in a particular month. The variable "InjuryLength" is how many months the individual was limited due to that injury. Sample below:
I want to transform the variable "Injury" to equal 1 for each month the individual is limited, based on the value in the variable "InjuryLength." So the resulting dataset would look as follows:
Any thoughts would be greatly appreciated.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(ID Month Injury InjuryLength) 1 1 0 . 1 2 0 . 1 3 1 6 1 4 0 . 1 5 0 . 1 6 0 . 1 7 0 . 1 8 0 . 1 9 0 . 1 10 0 . 1 11 0 . 1 12 0 . 2 1 0 . 2 2 0 . 2 3 0 . 2 4 0 . 2 5 0 . 2 6 1 3 2 7 0 . 2 8 0 . 2 9 0 . 2 10 0 . 2 11 0 . 2 12 0 . end
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(ID Month Injury InjuryLength) 1 1 0 . 1 2 0 . 1 3 1 6 1 4 1 . 1 5 1 . 1 6 1 . 1 7 1 . 1 8 1 . 1 9 0 . 1 10 0 . 1 11 0 . 1 12 0 . 2 1 0 . 2 2 0 . 2 3 0 . 2 4 0 . 2 5 0 . 2 6 1 3 2 7 1 . 2 8 1 . 2 9 0 . 2 10 0 . 2 11 0 . 2 12 0 . end
Comment