Hi,

I have previously posted here and received great help. Need help with one last area that I am really struggling with. I am trying to find the type of procedure that occurs for the second procedure. My data shown below is in long format. There are multiple observations per id number.

date_order is the order of the procedure with date_order 2 correlating to the 2nd procedure I am trying to identify.

_j is procedure they had, with _1, _2, and _3 all representing different procedures.

If patients only received one procedure as their 2nd procedure, i.e. only _j == _1 & date_order==2 it would be easy. But some patients received 2 different procedures on their second procedure (or date_order == 2). For example, id = 2 received procedure _1 and procedure _2. I want to create a variable that captures patients who had two procedures for their date_order ==2 and cannot figure it out.

Any help?

----------------------- copy starting from the next line -----------------------
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input float id long date_order str2 _j float proc
2 2 "_1" 43
2 2 "_2" .
2 2 "_2" 42
2 2 "_3" .
2 2 "_3" .
2 2 "_1" .
9 2 "_1" 336
9 2 "_2" .
9 2 "_3" .
9 2 "_2" .
9 2 "_3" .
9 2 "_1" 336
9 2 "_1" 336
9 2 "_2" .
9 2 "_1" 336