BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alexdsa310
Obsidian | Level 7

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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.

View solution in original post

4 REPLIES 4
Astounding
PROC Star

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

alexdsa310
Obsidian | Level 7

I am using this for table creation and specifying start date and end date from adsl in macro call for AE tables

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1526 views
  • 0 likes
  • 3 in conversation