Programming the statistical procedures from SAS

Error in Weekday() function

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Error in Weekday() function

Hi there,

I am trying to use the weekday function but I am having some error. If someone could help me out here that would be great! Thanks.

I am doing a simple:

weekday=weekday(occurred_at) but keep getting errors. Not sure why.

Below is the result from proc contents:

6 occurred_at Num 8 DATETIME. DATETIME.


Accepted Solutions
Solution
‎08-26-2015 08:35 AM
SAS Super FREQ
Posts: 3,304

Re: Error in Weekday() function

According to the doc

SAS(R) 9.4 Functions and CALL Routines: Reference, Fourth Edition

the WEEKDAY function expects a date, rather than a datetime.  Try this:

weekday = weekday(datepart(occurred_at));

View solution in original post


All Replies
Solution
‎08-26-2015 08:35 AM
SAS Super FREQ
Posts: 3,304

Re: Error in Weekday() function

According to the doc

SAS(R) 9.4 Functions and CALL Routines: Reference, Fourth Edition

the WEEKDAY function expects a date, rather than a datetime.  Try this:

weekday = weekday(datepart(occurred_at));

Occasional Contributor
Posts: 10

Re: Error in Weekday() function

Thank you, Rick!

☑ This topic is SOLVED.

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

Discussion stats
  • 2 replies
  • 278 views
  • 0 likes
  • 2 in conversation