I'm trying trying to sort: Week 2, Week 12, Week 16, Week 8, Week 4 in ascending order of week number, but could not get the order. Any suggestions please?
It is not clear what type of variables you have.
Assuming the variable is character then you will get it sorted like:
'Week 12' 'Week 16' 'Week 2 ' 'Week 4 ' 'Week 8 '
in order to get it in order of the week number, you need keep the number as a separate numeric variable
to get it in order: 2 4 8 12 16.
it is not very clear what you want to achieve. if you can show sample input data and result you want, someone will be able to help you
It is not clear what type of variables you have.
Assuming the variable is character then you will get it sorted like:
'Week 12' 'Week 16' 'Week 2 ' 'Week 4 ' 'Week 8 '
in order to get it in order of the week number, you need keep the number as a separate numeric variable
to get it in order: 2 4 8 12 16.
You can create a new variable which is just the week number and use that’s to sort.
You can also look into the collating sequence options within PROC sort.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.