Hello (and thank you in advance for any help),
I have a panel dataset (with variable id as the cross-section and time as the time dimension). I have attached example data to this post. The variable Mark currently indicates the first time the id gets a treatment. However, I want to replace "Mark" such that all times after the first treatment (for each id) also receive a "1" and that all values prior to the first treatment get a "0". For example, for id 1 and time 4, there should be a "1" in Mark. For id 2, there should be a "1" in Mark for times 3 and 4 also.
Can anyone help with generating a code that will solve this problem (as I will apply it to a larger dataset)? Thank you for any help you can provide!
I have a panel dataset (with variable id as the cross-section and time as the time dimension). I have attached example data to this post. The variable Mark currently indicates the first time the id gets a treatment. However, I want to replace "Mark" such that all times after the first treatment (for each id) also receive a "1" and that all values prior to the first treatment get a "0". For example, for id 1 and time 4, there should be a "1" in Mark. For id 2, there should be a "1" in Mark for times 3 and 4 also.
Can anyone help with generating a code that will solve this problem (as I will apply it to a larger dataset)? Thank you for any help you can provide!
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(id time Mark) 1 1 . 1 2 . 1 3 1 1 4 . 2 1 . 2 2 1 2 3 . 2 4 . end

Comment