BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
smackerz1988
Pyrite | Level 9

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.  

 

SUBJIDTRTSDTTRTEDTASTDTAENDTONTRTFL
100107Jun202216Jun202211Jun202214Jun2022Y
100227May202220Jul202201Jan200601Jan2006 
100327May202220Jul202201Jan202020Jul2022 
100415Jun202214Jul202218Jun202203Jul2022Y
100515Jun202214Jul202201Jan197014Jul2022 
1 ACCEPTED SOLUTION

Accepted Solutions
smackerz1988
Pyrite | Level 9

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';

 

View solution in original post

6 REPLIES 6
PaigeMiller
Diamond | Level 26

Please provide context and explanation. Provide portions of sample data sets.

--
Paige Miller
smackerz1988
Pyrite | Level 9

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

 

SUBJIDTRTSDTTRTEDTASTDTAENDT
100127Apr202221Jul202201Jan2021 
100227Apr202220Jul202201Jan2018 
100307Jun202216Jun202201Jan2000 
100427May202220Jul202201Jan2005 
100427May202220Jul202201Jan200601Jan2006
PaigeMiller
Diamond | Level 26

So am I correct in understanding that these time period overlap for the first 4 records but not for the fifth?

--
Paige Miller
smackerz1988
Pyrite | Level 9
Ah no I believe none of the records overlap. If say ASTDT was 01MAY2022 and AEENDT was 02MAY2022 for subject 1001 then ONTRTFL would = Y as the period between ASTDT and AEENDT (01MAY2022 -02MAY2022) overlaps with the period between TRSTDT AND TRTEDT (27APR2022 -21JUL2022). This is interim data atm but all columns should be populated
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
smackerz1988
Pyrite | Level 9

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';

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 666 views
  • 0 likes
  • 2 in conversation