Here is the below code which i am using and the studystart and end is coming as 01JAN1960 for all.
The input dataset TRTSDT and TRTEDT has both date9. format and numeric. I am not sure why it is converting to 01JAN1960
%macro ndtv(StudyStart=TRTSDT,
StudyEnd=TRTEDT
);
data inc;
format STUDY_START STUDY_END date9.;
set adam.adsl;
STUDY_START = datepart(&StudyStart.);
STUDY_END = datepart(&StudyEnd.);
run;
%mend;
%ndtv;
The DATEPART function should only be applied to SAS DATETIME values, not to SAS DATE values. Evidently, your incoming variables (TRTSDT and TRTEDT) are already SAS dates. You can simply replace those two lines of your DATA step with:
STUDY_START = &StudyStart.;
STUDY_END = &StudyEnd.
The DATEPART function should only be applied to SAS DATETIME values, not to SAS DATE values. Evidently, your incoming variables (TRTSDT and TRTEDT) are already SAS dates. You can simply replace those two lines of your DATA step with:
STUDY_START = &StudyStart.;
STUDY_END = &StudyEnd.
Hi, bit off topic, what is the purpose of this code? You have ADaM datasets (which are the basis for analysis) with the date variables already present, why the intermediary step to duplicate variables?
TRTSDT indicates a date variable - i.e. doesn't contain timepart, which is why I question the code, as it doesn't actually do anything?
I am using this for table creation and specifying start date and end date from adsl in macro call for AE tables
Yes, but you already have those two variables? If you have:
TRTSTDT TRTETDT
01JAN2017 10JAN2017
After your code you would have:
TRTSTDT TRTETDT STUDY_START STUDY_END
01JAN2017 10JAN2017 01JAN2017 10JAN2017
It just doesn't make sense to me, you would have to explain that extra code in your reviewers guide as well?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.