Exploring, predicting and reporting with SAS Visual Analytics and SAS Visual Statistics

WeekNumber as Time or Date Format

Reply
Contributor
Posts: 28

WeekNumber as Time or Date Format

Hello,

 

I have been using WeekNumber('Date Curing (Shift)'n) function to extract the Week number from the Date. The default format is Numeric and I want to have it in Date or Time Format as I am using this as a category in Bar Chart and I want to see the order of the dates.

 

For eg : If I select the dates from 15 DEC 2017 - 15 JAN 2018 It should display the WEEK NUMBER 51 52 01 02 in this order but due to its Numeric Data Type it is showing in the order 01 02 51 52 .

 

is there any way to change the format or any other calculation?

 

Thanks !!

Super User
Super User
Posts: 9,829

Re: WeekNumber as Time or Date Format

A week number is not a date or a time.  A date is number of days since the cuttoff point, time is number of seconds since 00:00.

 

Week number alone is not sufficient information to present data across years.  Year at minimum is required.  Therefore you need to check the requirements of the output, and suggest that week be used in conjunction with year to present data accurately, otherwise is week 1 the first week of 2017 or 2018?  You know that as you have the year the reviewer does not.  I would suggest putting the date into Year-Week format, then displaying that.

Contributor
Posts: 28

Re: WeekNumber as Time or Date Format

I think there is no default format for YEAR-WEEK as well.

I have added a drop down for YEAR along with the weeks. Its working fine now.

 

Thank you for your suggestion.

 

New Contributor
Posts: 2

Re: WeekNumber as Time or Date Format

I have also used the approach of tracking the WeekNumber values by using a Year value dropdown list.  The drawback is that you cannot then visualize across the calendar year boundaries.  Since the customer really wanted to see a date (and not a week number) I found it easy to just choose a date value for each week (Saturday date value in my case) then use that date to represent the week in question. It works well and I actually compute it directly from the date values using the intnx function, in SAS code in the source data processing step.

 

FYI for general use, the WeekNumber as calculated by the WeekNumber function can result in values of 00 or 53, depending on the year.

Contributor
Posts: 28

Re: WeekNumber as Time or Date Format

Posted in reply to mskatymay

Exactly, it depends upon the customer how he wants to see the output and it should be relevant with the filters used. I have added date variable in a slider and then used weeks in a Bar chart to show the output.

Thanks for your Input @mskatymay 

Ask a Question
Discussion stats
  • 4 replies
  • 181 views
  • 1 like
  • 3 in conversation