Hi All,
I have a question related to comparing one observation with next observation, Where same PT, and same TRT and DOSE_TXT and CMROUTE.
1)CMSTDAT_DTS of one record is prior to the CMENDATC_DT of another record or 2)where CMSTDAT_DTS of record where CMONGO is checked is prior to the CMENDATC_DT of another record or 3)where multiple events with CMONGO is checked.
Flag all events of same subject, cmtrt and cmdstxt and cmroute as 'Y'.
Here is the sample data.
pt trt route dose_txt st_dt end_dt cmongo flag
1 aquaphor (Emollient Ointment) Topical (TOP) 1 2017-01-22 2017-01-28 1 aquaphor (Emollient Ointment) Topical (TOP) 1 2017-01-28 Ongoing 2 NaCl 0.9% Intravenous (IV) 20 2018-07-28 Ongoing Y ...satisfying condition 3 2 NaCl 0.9% Intravenous (IV) 20 2018-08-17 Ongoing Y ...satisfying ondition 3 2 Penicillin V Potassium Oral (PO) 500 2018-07-05 2018-07-08 2 Penicillin V Potassium Oral (PO) 500 2018-07-11 2018-07-16 2 Penicillin V Potassium Oral (PO) 500 2018-07-20 2018-07-28 Y 3 furosemide Intravenous (IV) 20 2018-03-30 2018-03-30 3 furosemide Intravenous (IV) 20 2018-03-30 Ongoing Y ...satisfying condition 2 3 furosemide Intravenous (IV) 20 2018-04-30 2018-04-30 Y
I'm trying to do this way but not working. can you please suggest me how to proceed.
/* pulling the records having same subject, cmtrt and cmdstxt and cmroute*/ proc sql; create table tst as select PT,TRT,dos_txt,ROUTE ,st_dt, end_dt , CMONGO, count(pt) as cnt from tbl_13 group by PT,TRT,dos_txt,ROUTE order by PT,TRT,dos_txt,ROUTE,st_dt; quit;
data tst1; set tst; by PT,TRT,dos_txt,ROUTE; where cnt>1; /* if CMONGO ne " " and lag(CMONGO) ne " " and CMONGO=lag(CMONGO) then flag2="Y"; */ /* else if CMONGO eq " " and lag(CMONGO) eq " " and CMSTDATN > lag(CMENDATCN) then flag2="Y";*/ /* else if CMONGO ne " " and lag(CMONGO) eq " " and CMSTDATN < lag(CMENDATCN) then flag2="Y";*/
run;
Thanks in advance.
... View more