Hi,
Okay this is not my strong point but can someone help me with this specification for ONTRTFL
If any of the period between ASTDT and AENDT (inclusive) overlaps with the period between ADSL.TRTSDT and ADSL.TRTEDT (inclusive) then set to "Y". |
I guess it's just the overlapping that is throwing me off but I'm sure it's something simple that I'm not considering. ONTRTFL is On Treatment Flag for an ADCM dataset. So if someone is given concomitant medication and it coincides with when they were also being given the investigational drug then it should be flagged as Y. For example, subject 1001 ASTDT was 11JUN2022 and AEENDT was 14JUN2022 then ONTRTFL would = Y as the period between ASTDT and AEENDT (11JUN2022 - 14JUN2022) overlaps with the period between TRSTDT AND TRTEDT (07JUN2022 -16JUN2022). The same applies to subject 1004 but not for subjects 1002,1003 or 1005 as the ASTDT/AEENDT time period doesn't overlap with TRTSDT/TRTEDT.
SUBJID | TRTSDT | TRTEDT | ASTDT | AENDT | ONTRTFL |
1001 | 07Jun2022 | 16Jun2022 | 11Jun2022 | 14Jun2022 | Y |
1002 | 27May2022 | 20Jul2022 | 01Jan2006 | 01Jan2006 | |
1003 | 27May2022 | 20Jul2022 | 01Jan2020 | 20Jul2022 | |
1004 | 15Jun2022 | 14Jul2022 | 18Jun2022 | 03Jul2022 | Y |
1005 | 15Jun2022 | 14Jul2022 | 01Jan1970 | 14Jul2022 |
I've updated the original post for clarity and after thinking about it this seems like the solution.
* ONTRTFL *; if cmiss(ASTDT,AENDT,TRTSDT,TRTEDT) = 0 then do; OVERLAP = max(0, min(TRTEDT,AENDT)- max(TRTSDT,ASTDT)+1); end; If OVERLAP > 1 then ONTRTFL = 'Y';
Please provide context and explanation. Provide portions of sample data sets.
Here is a small portion of the relevant data. ONTRTFL is On Treatment Flag for an ADCM dataset. So if someone is given concomitant medication and it coincides with when they were also being given the investigational drug then it should be flagged as Y
SUBJID | TRTSDT | TRTEDT | ASTDT | AENDT |
1001 | 27Apr2022 | 21Jul2022 | 01Jan2021 | |
1002 | 27Apr2022 | 20Jul2022 | 01Jan2018 | |
1003 | 07Jun2022 | 16Jun2022 | 01Jan2000 | |
1004 | 27May2022 | 20Jul2022 | 01Jan2005 | |
1004 | 27May2022 | 20Jul2022 | 01Jan2006 | 01Jan2006 |
So am I correct in understanding that these time period overlap for the first 4 records but not for the fifth?
What is the proper thing to do if AENDT is missing? What do you mean by "This is interim data atm but all columns should be populated"? Can you show us data where all the fields are populated (even if it is made up) to illustrate the different possibilities of overlapping time periods or not overlapping time periods?
I think it would be helpful if you started over and explained all of this completely and clearly and completely and clearly rather than me having to piece together various different statements of yours which I have been confused by.
I've updated the original post for clarity and after thinking about it this seems like the solution.
* ONTRTFL *; if cmiss(ASTDT,AENDT,TRTSDT,TRTEDT) = 0 then do; OVERLAP = max(0, min(TRTEDT,AENDT)- max(TRTSDT,ASTDT)+1); end; If OVERLAP > 1 then ONTRTFL = 'Y';
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.