10-02-2016 01:01 PM - last edited on 10-03-2016 03:36 AM by LinusH
I hope one of you can help me.
I have an observation for every diagnosis given to a patient.
I have a variable called removal (if the patient has been removed to another hospital on the same day the patient has been discharge from the first hospital).
I would like to find out if the diagnosis given at the first hospital is the same as the diagnosis given at the second hospital.
Example of my dataset
ID Diag Admission Discharge Removal
1 DI451 Date Date 0/1
1 ... .... .... ....
Can anybody please give an advise?
10-02-2016 04:06 PM
Ok, somehow join the record to the previous record (SQL Join) or sort your data and use LAG to retrieve the diagnosis code.
If the diagnosis is different set it to 0, otherwise set it to 1.