Hello Statalisters,

I am starting in the world of Stata and I would appreciate suggestions on how to approach the following. (Stata 14.2 IC for Mac)

I have a dataset with aprox. 60 numeric variables (pres_visit1 through pres_visit60) of pressure readings during consecutive visits to the doctor for about 500 patients. The dataset looks like this (resumed version):
pres_visit1 pres_visit2 pres_visit4 pres_visit5 pres_visit6 pres_visit7
patient1 12 13 9 9 11 12
patient2 19 16 18 19 15 14
patient3 21 20 15 16 19 18
patient4 21 22 22 20 24 .
patient5 12 13 11 . . .
patient6 19 15 17 18 20 .
I need to identify, across variables "pres_visit1" to "pres_visit50" the first time a patient has 2 consecutive readings ≥17. The output could be generating a new variable "failure" ==1 when a patient experienced the event "2 consecutive readings above 17", and ideally, another variable displaying varname of the first of these 2 consecutive readings ≥17.

In other words, I need to evaluate for each patient, the first variable with a value of "≥17" and only if this is met, then determine if the immediate next variable is also "≥17" and repeat this until it finds the first pair of such qualifying values.

I greatly appreciate your time and knowledge,

Alan Kastner.