Hi,
I am trying to merge two datasets (or extract information from one dataset using another) and I am running into some problems and would love to have somebody's opinion on what the best way to proceed:
- My first dataset includes amongst other variables : id (patient's unique identifier), date1 (the date of their surgery). This dataset includes only patients from my whole cohort who have had a surgery.
Here is an example from dataex command: input str10 id long date1
"1002706622" 17179
"1004835910" 15929
"1005071077" 15620
-My second dataset includes amongst other variables: id (patient's unique identifier), no_seq_sej_hosp (an identification specific to each hospitalization), date_admis (admission date), date_depart (discharge date), date_arriv (date patients arrived to the ER). This dataset includes information on all hospitalizations for all patients in my cohort. So one patient will have one "id" but can have different "no_seq_sej_hosp" as they can have different hospitalizations for different reasons.
Here is an an example from dataex command:
input str10 id str16 no_seq_sej_hosp long(date_admis date_depart)
"0057128888" "9956322975623467" 14418 14420
"0057128888" "2954352785623469" 14101 14101
"0057128888" "9951302355603363" 15596 15601
"0057128888" "9957372985683867" 17078 17085
"0165250763" "0957382445643364" 16019 16030
"0165250763" "1956382275683369" 16554 16554
So a single patient could've been hospitalized for a variety of reasons, but I am only interested in the ones who have a hospitalization for surgery which are patients in the first dataset, and these patients will inevitably have their date1 from the first dataset included between date_depart and date_admis from the second dataset, and their hospitalization code no_seq_sej_hosp will then allow me to find these specific hospitalizations in different datasets.
Is there any way I can extract from the second dataset information only concerning patients who are in the first dataset by using the fact that their hospitalization day has to be included between the date_depart and date_admis of the second dataset?
I would really appreciate anybody's insight,
Thank you for your help,
Maria Abou Khalil
I am trying to merge two datasets (or extract information from one dataset using another) and I am running into some problems and would love to have somebody's opinion on what the best way to proceed:
- My first dataset includes amongst other variables : id (patient's unique identifier), date1 (the date of their surgery). This dataset includes only patients from my whole cohort who have had a surgery.
Here is an example from dataex command: input str10 id long date1
"1002706622" 17179
"1004835910" 15929
"1005071077" 15620
-My second dataset includes amongst other variables: id (patient's unique identifier), no_seq_sej_hosp (an identification specific to each hospitalization), date_admis (admission date), date_depart (discharge date), date_arriv (date patients arrived to the ER). This dataset includes information on all hospitalizations for all patients in my cohort. So one patient will have one "id" but can have different "no_seq_sej_hosp" as they can have different hospitalizations for different reasons.
Here is an an example from dataex command:
input str10 id str16 no_seq_sej_hosp long(date_admis date_depart)
"0057128888" "9956322975623467" 14418 14420
"0057128888" "2954352785623469" 14101 14101
"0057128888" "9951302355603363" 15596 15601
"0057128888" "9957372985683867" 17078 17085
"0165250763" "0957382445643364" 16019 16030
"0165250763" "1956382275683369" 16554 16554
So a single patient could've been hospitalized for a variety of reasons, but I am only interested in the ones who have a hospitalization for surgery which are patients in the first dataset, and these patients will inevitably have their date1 from the first dataset included between date_depart and date_admis from the second dataset, and their hospitalization code no_seq_sej_hosp will then allow me to find these specific hospitalizations in different datasets.
Is there any way I can extract from the second dataset information only concerning patients who are in the first dataset by using the fact that their hospitalization day has to be included between the date_depart and date_admis of the second dataset?
I would really appreciate anybody's insight,
Thank you for your help,
Maria Abou Khalil
Comment