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: Call for Content

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!

Submit your idea!

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
  • 4 replies
  • 1448 views
  • 0 likes
  • 3 in conversation