BookmarkSubscribeRSS Feed
narulap
Obsidian | Level 7

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 !!

4 REPLIES 4
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

narulap
Obsidian | Level 7

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.

 

mskatymay
Calcite | Level 5

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.

narulap
Obsidian | Level 7

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 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Tips for filtering data sources in SAS Visual Analytics

See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1678 views
  • 1 like
  • 3 in conversation