Hello,
I am re-running a Do file from my colleagues and trying to understand some of the codes they have written. However, I am struggling to understand one of them involving egen and max/min functions.
For context: I have a data with patients attending clinics for diagnosis of a disease. 1 patient can have multiple attendances at the clinic and 1 attendance can have multiple rows depending upon the diagnosis.
I have to create a new date variable where it will take the first attendance date the patient was diagnosed with disease X (coded by X), and this has to be populated for all of the attendances of that patient. (in order to flag that patient is diagnosed with the disease)
The code that I have been given is :
egen date_new = min(attendance_date/(disease_code == X)), by(clinic_code patient_id)
where attendance_date is date of the attendances; disease_code is the codes given at the time of diagnosis; clinic_code is the code for clinics the patient attended; pateint_id is the unique patient ID.
In the above code, I do not understand the use of backward slash (/) with the min function.
I would really appreciate any help with this please.
Thank you
Kritika
I am re-running a Do file from my colleagues and trying to understand some of the codes they have written. However, I am struggling to understand one of them involving egen and max/min functions.
For context: I have a data with patients attending clinics for diagnosis of a disease. 1 patient can have multiple attendances at the clinic and 1 attendance can have multiple rows depending upon the diagnosis.
I have to create a new date variable where it will take the first attendance date the patient was diagnosed with disease X (coded by X), and this has to be populated for all of the attendances of that patient. (in order to flag that patient is diagnosed with the disease)
The code that I have been given is :
egen date_new = min(attendance_date/(disease_code == X)), by(clinic_code patient_id)
where attendance_date is date of the attendances; disease_code is the codes given at the time of diagnosis; clinic_code is the code for clinics the patient attended; pateint_id is the unique patient ID.
In the above code, I do not understand the use of backward slash (/) with the min function.
I would really appreciate any help with this please.
Thank you
Kritika
Comment