BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
blewsas
Obsidian | Level 7

I have created a "Day of Week" calculated item from a date field.  I'd like to apply a custom sort so that the first day of the week is Monday, rather than Sunday.  However, when I right-click on the "Day of Week" category, the "custom sort" option is not available.  Any ideas?  SAS VA 8.3

1 ACCEPTED SOLUTION

Accepted Solutions
FredrikE
Rhodochrosite | Level 12

Hi!

Try this 🙂

 

Create a new calculated item (character) and add this code:

 

IF ( DayOfWeek('Date'n) = 1 )
RETURN 'Sunday'
ELSE (
IF ( DayOfWeek('Date'n) = 2 )
RETURN 'Monday'
ELSE (
IF ( DayOfWeek('Date'n) = 3 )
RETURN 'Tuesday'
ELSE (
IF ( DayOfWeek('Date'n) = 4 )
RETURN 'Wednesday'
ELSE (
IF ( DayOfWeek('Date'n) = 5 )
RETURN 'Thursday'
ELSE (
IF ( DayOfWeek('Date'n) = 6 )
RETURN 'Friday'
ELSE (
IF ( DayOfWeek('Date'n) = 7 )
RETURN 'Saturday'
ELSE '-' ) ) ) ) ) )

 

Then add the custom sort.

 

//Fredrik

View solution in original post

5 REPLIES 5
FredrikE
Rhodochrosite | Level 12

Hi!

Are you creating a string variable with the weekday name?

 

If not maybe you should try that, it might solve both the sorting and the difference between the editor and report mode.

 

//Fredrik

blewsas
Obsidian | Level 7

my calculation is

  DatePart('Offence TMST'n)

And I am applying the "Day of Week" format to this.

What should I be doing differently?

Thanks!

blewsas
Obsidian | Level 7

 

That gives me what I want -  "Offence Days of Week" of "Sunday", "Monday", "Tuesday", etc.  However, I have the same problem when I view the report - they change to "03Jan1960", "04Jan1960", "05Jan1960", etc.

 

And I can't custom sort them.

 

Help!  Very frustrating!

FredrikE
Rhodochrosite | Level 12

Hi!

Try this 🙂

 

Create a new calculated item (character) and add this code:

 

IF ( DayOfWeek('Date'n) = 1 )
RETURN 'Sunday'
ELSE (
IF ( DayOfWeek('Date'n) = 2 )
RETURN 'Monday'
ELSE (
IF ( DayOfWeek('Date'n) = 3 )
RETURN 'Tuesday'
ELSE (
IF ( DayOfWeek('Date'n) = 4 )
RETURN 'Wednesday'
ELSE (
IF ( DayOfWeek('Date'n) = 5 )
RETURN 'Thursday'
ELSE (
IF ( DayOfWeek('Date'n) = 6 )
RETURN 'Friday'
ELSE (
IF ( DayOfWeek('Date'n) = 7 )
RETURN 'Saturday'
ELSE '-' ) ) ) ) ) )

 

Then add the custom sort.

 

//Fredrik

blewsas
Obsidian | Level 7

Thanks, that would work.  I took a different, but similar, path - I created a custom category called "Offence DOW" based on my "Offence Day of Week" values and used them instead.

 

custom category.jpg

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 5 replies
  • 1832 views
  • 3 likes
  • 2 in conversation