Hi,
I am new to stata. I have tried to find the answer to my question in FAQ but I didn't find exactly what I wanted, so I post it here.
I am working with a database with different observationssome of them from the same patients. Each observation is a test and has a date and a result. I would like to select patients that have with one test performed at a specific date and another one after another date. Each patient could have more than one test that meets the criteria.
id testdate testresult
1 01jan2022 4000
1 09sept2022 3000
1 10sept2022 3050
2 03jan2022 4000
2 25sept2022 3000
3 28sept2022 3050
4 02feb2022 1500
4 25sept2022 3000
First, I tried creating a dummy variable to select identifiy if the test meet the criteria:
generate dateselect= 1 if (tesdate>date("January 1 2022","MDY"))
replace dateselect=2 if (tesdate>date("September 1 2022","MDY"))
replace dateselect=0 if dateslect==.
and do a reshape but as dateselect could have the same value in several observations from the same patient, it didn't work.
Could some help me out?
Thank you very much
I am new to stata. I have tried to find the answer to my question in FAQ but I didn't find exactly what I wanted, so I post it here.
I am working with a database with different observationssome of them from the same patients. Each observation is a test and has a date and a result. I would like to select patients that have with one test performed at a specific date and another one after another date. Each patient could have more than one test that meets the criteria.
id testdate testresult
1 01jan2022 4000
1 09sept2022 3000
1 10sept2022 3050
2 03jan2022 4000
2 25sept2022 3000
3 28sept2022 3050
4 02feb2022 1500
4 25sept2022 3000
First, I tried creating a dummy variable to select identifiy if the test meet the criteria:
generate dateselect= 1 if (tesdate>date("January 1 2022","MDY"))
replace dateselect=2 if (tesdate>date("September 1 2022","MDY"))
replace dateselect=0 if dateslect==.
and do a reshape but as dateselect could have the same value in several observations from the same patient, it didn't work.
Could some help me out?
Thank you very much
Comment