I'm hoping someone can help me with the following:
The following is my dataset:
MKT RB_FLAG DATE1 DATE2
A RB 19SEP 17OCT
A NRB 19SEP 24OCT
A RB 19SEP 21NOV
B NRB 17OCT 17OCT
B RB 17OCT 24OCT
B RB 17OCT 14NOV
B NRB 17OCT 29DEC
B RB 17OCT 16JAN
B NRB 17OCT 23JAN
For each MKT I need to take the first instance when RB_FLAG="RB" and the first instance after where RB_FLAG="NRB" then calculate the difference between DATE1 (for RB) and DATE2 (for NRB). Also, I'm only interested in the first occurence of RB within a MKT. Ultimately, I'm trying to arrive at the following table:
MKT RB_FLAG DATE1 DATE2 WEEK_DIFF
A RB 19SEP 24OCT 5
B RB 17OCT 19DEC 10
I have read some similar posts on "looking ahead" within a datastep but I'm struggling to adapt the suggestions to my problem.
Thank you ahead of time for you help on this!
Rich