BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi Guys,

I am working on a line graph where my x-axis is day of the week . Is there a way where I can have X axis by the following order:

Mon Tue Wed Thu Wed Fri Sat Sun

Because the column is a string It give me the following order:
Friday Monday Sat Sun Tue Thu Wed
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest you may want to analyze your "internal" data variable values for the X axis. Also, consider posting your complete SAS code as it appears in the SAS log output with COPY/PASTE into a reply to your post.

Scott Barry
SBBWorks, Inc.
RichardH_sas
SAS Employee
Hmm, there are two solutions I can think of, one easy, one harder but a bit more professional.

The easy solution would be to recode the character values in your day of week column to the following.
1 - Mon
2 - Tue
3 - Wed
etc.

Because you literally have a number in front of the day, when the GRAPH code alphabetizes the X axis, you'll get the order you want. The only problem with this is you may not like the fact that you'll see the 1, 2, etc. in front of the weekdays.

The harder way is to recode the character column to have values like above, create a custom format, and then apply that custom format in the line plot task. There is a task for this (Create Format), and you'd want a value like "1 - Mon" to be displayed as "Monday". After creating the format, you'd need to apply it to the column in question. This typically can only be done within the task dialog interface, not in the wizard interface. So, if you are currently using the Line Plot Wizard, right-click, and open in advanced view to get the task dialog interface.

Let me know if you need more details.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1139 views
  • 0 likes
  • 3 in conversation