TRTENDT derivation


I am calculating

TRTEDT Date of Last Exposure to Treatment integer 8 DATE9. The date of final dose (from the CRF) is EX.EXENDTC on the subject's last EX record. If the date of final dose is missing for the subject and the subject discontinued after visit 3, use the date of discontinuation as the date of last dose. Convert the date to a SAS date. \line

for this I am doing

ex_01 <- arrange (select (ex , usubjid , exseq , extrt , visit, visitnum , exendtc) , usubjid , visitnum )
ex_02 <- ex_01 %>%
arrange (usubjid , visitnum) %>%
group_by (usubjid ) %>%
summarise_all (last)

in the Ex dataset there are couple of missing dates , I want to

  1. convert the exendtc to date format so that I can do some calculations using it
  2. Not sure how to separate the missing dates


mutate(ex_02,exendtc = as.Date(exendtc))

Can you say more about what seperate means to you in this context ?

Hmm , Thanks a lot I tried to convert date using as.Date function did not work earlier . Thanks a lot it worked , I tried even using lubridate , how do we do it using lubridate and stringr libraries ( Trying to learn syntax)

I see what happening , in my ex data there 6 records with no dates ( The source is .sasxpt file ) so the missing character is " " empty , when I did then it was giving me an error "Error in : could not find function" . I did not see 'NA' as the missing .

The logic I have used to filter the Missing records is

ex_02_missing_date <- filter(ex_02 , trtedt < 0 ) ( Less then zero for missing dates and >0 for non missing dates ) .

This is strange behavior to filter Character values with Numeric ?

Be aware R is case sensitive so is different from as.Date

Yes off course as.Date ( R studio helps me with these things ) ,

Did not get answer for
ex_02_missing_date <- filter(ex_02 , trtedt < 0 ) ( how does R process it ?)

How to process date in other packages lubridate?


NA values are not less than 0.
You can detect them with function

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.