Hello,

I would like to create a variable, called "outcome", measured as a dummy indicator equal to one if Plan B was implemented (variable Plan B = 1) within 30 days from the implementation of Plan A (variable Plan A = 1). Note that within an id, there could be multiple plans A and B. I send an example of the dataset below. Thank you very much in advance.

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input byte id str9 date byte(plan_A plan_B outcome)
1 "21-Jan-14" 0 0 0
1 "8-Jul-14"  0 1 0
1 "5-Aug-14"  1 0 0
1 "1-Sep-14"  0 1 1
1 "5-Mar-15"  0 0 0
1 "28-Nov-15" 0 0 0
1 "5-Sep-17"  1 0 0
1 "2-Nov-17"  0 1 0
2 "21-Mar-15" 0 0 0
2 "10-Apr-15" 1 0 0
2 "20-Apr-15" 0 1 1
2 "19-Dec-16" 0 1 0
2 "11-Jan-17" 0 0 0
2 "3-Jul-17"  0 0 0
end