DATA Step, Macro, Functions and more

Invalid argument to function YRDIF

Accepted Solution Solved
Reply
Regular Contributor
Posts: 199
Accepted Solution

Invalid argument to function YRDIF

[ Edited ]

I'm trying to calculate the difference in years between two dates using the YRDIF function and the following syntax:

 

DATA want;
  SET have;
  Yrdif_test = YRDIF(Part_RDATE, BH_Accomplished_Date, "Actual");
RUN;


I am getting an "invalid argument" warning and all the values are missing. 

 

The informats for these two dates are different.

Part_RDATE = mmddyy10

BH_Accomplished_Date=mdyampm25.2 (includes time)

 

The documentation makes no reference to differences in informats, or dates where one includes time.

 

A portion of the data is attached. As is the log. Thanks for your help.

 


Accepted Solutions
Solution
‎04-14-2016 06:07 PM
Super User
Posts: 3,250

Re: Invalid argument to function YRDIF

The documentation states that both start and end dates are both SAS date values not datetime. This should correct your statement:

 

DATA want;
  SET have;
  Yrdif_test = YRDIF(Part_RDATE, datepart(BH_Accomplished_Date), "Actual");
RUN;

View solution in original post


All Replies
Solution
‎04-14-2016 06:07 PM
Super User
Posts: 3,250

Re: Invalid argument to function YRDIF

The documentation states that both start and end dates are both SAS date values not datetime. This should correct your statement:

 

DATA want;
  SET have;
  Yrdif_test = YRDIF(Part_RDATE, datepart(BH_Accomplished_Date), "Actual");
RUN;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 359 views
  • 1 like
  • 2 in conversation