Dear STATAList forum,

I'm working with ophthalmic surgery data, trying to calculate which types of re-operations were subsequently undertaken for patients after their original operation.
The data is in long format (after use for a time till even analysis), and so I'm finding it difficult.

I've pasted the code below, if helpful;
- first_proc_date is the date of their original operation
- proc_date is useful in identifying who had a reoperation (i.e. if proc_date > first_proc_date, it must have been a reoperation)
- re_op_op1 is the binary variable denoting whether it was a reoperation
- istent, hydrys, istent_add, goniotomy, trabectome, concur_phaco, ab-int_canal, and other_glau_proc_code are the names of the original/reoperations

Thanks so much for your consideration.
William

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str43 id_no float(first_proc_date proc_date) str5 proc_code float proceye byte(istent hydrus istent_add goniotomy trabectome concur_phaco ab_int_canal) str5 other_glau_proc_code byte re_op_op1
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66999" 3 0 0 0 0 1 1 0 ""      0
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66999" 3 0 0 0 0 1 1 0 ""      0
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66999" 3 0 0 0 0 1 1 0 ""      0
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66999" 3 0 0 0 0 1 1 0 ""      0
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66999" 3 0 0 0 0 1 1 0 ""      0
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66999" 3 0 0 0 0 1 1 0 ""      0
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66999" 3 0 0 0 0 1 1 0 ""      0
"49ec671d4da491f12738eb517ff6Right" 19490 19490 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66999" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"5f63385542f78f87378a11a10870Right" 19813 19813 "66984" 3 0 0 0 0 1 1 0 ""      0
"b8b8d04046408e96445ac5694055Left"  21155 21155 "66984" 2 0 0 0 0 1 1 0 ""      0
"b8b8d04046408e96445ac5694055Right" 21162 21162 "66999" 3 0 0 0 0 1 1 0 ""      0
"b8b8d04046408e96445ac5694055Right" 21162 21162 "66999" 3 0 0 0 0 1 1 0 ""      0
"b8b8d04046408e96445ac5694055Right" 21162 21162 "66999" 3 0 0 0 0 1 1 0 ""      0
"b8b8d04046408e96445ac5694055Right" 21162 21162 "66999" 3 0 0 0 0 1 1 0 ""      0
"b8b8d04046408e96445ac5694055Right" 21162 21162 "66999" 3 0 0 0 0 1 1 0 ""      0
"ca7c12494668b13bb0a591b1744bLeft"  20918 20918 "66984" 2 0 0 0 0 1 1 0 ""      0
"ca7c12494668b13bb0a591b1744bRight" 20904 20904 "66999" 3 0 0 0 0 1 1 0 ""      0
"173042a24cb28834472bd087e9ccRight" 21191 21191 "66999" 3 0 0 0 0 1 1 0 ""      0
"173042a24cb28834472bd087e9ccRight" 21191 21191 "66999" 3 0 0 0 0 1 1 0 ""      0
"173042a24cb28834472bd087e9ccRight" 21191 21191 "66999" 3 0 0 0 0 1 1 0 ""      0
"173042a24cb28834472bd087e9ccRight" 21191 21191 "66999" 3 0 0 0 0 1 1 0 ""      0
"173042a24cb28834472bd087e9ccRight" 21191 21191 "66999" 3 0 0 0 0 1 1 0 ""      0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"1cd755264e7bb2ddd39de53446f1Left"  20318 20318 "66174" 2 0 0 0 0 0 1 1 "66180" 0
"61ef797e4809a3e61f98b6d80749Left"  21287 21287 "66984" 2 0 0 0 0 1 1 0 ""      0
"61ef797e4809a3e61f98b6d80749Right" 21252 21252 "66999" 3 0 0 0 0 1 1 0 ""      0
"61ef797e4809a3e61f98b6d80749Right" 21252 21252 "66999" 3 0 0 0 0 1 1 0 ""      0
"61ef797e4809a3e61f98b6d80749Right" 21252 21252 "66984" 3 0 0 0 0 1 1 0 ""      0
"61ef797e4809a3e61f98b6d80749Right" 21252 21252 "66999" 3 0 0 0 0 1 1 0 ""      0
"6b03a339429fa622dfdb33d3a276Left"  20784 20784 "66984" 2 0 0 0 0 1 1 0 ""      0
"6b03a339429fa622dfdb33d3a276Right" 20811 20811 "66984" 3 0 0 0 0 1 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
"df54663c4ed093efc3c5e2feddebRight" 20764 20764 "66984" 3 1 1 0 0 0 1 0 ""      0
end
format %td first_proc_date
format %td proc_date
label values proceye _slt_eye
label def _slt_eye 2 "Left", modify
label def _slt_eye 3 "Right", modify