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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.