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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.