Example 8.6 Creating a Customized Sort Order without Adding a New Column to the Table
Sort the rows in a table in a customized, complex order. Define a new column temporarily to hold the sort order and do not save it in the output table.
|Featured Step||PROC SQL|
|Featured Step Options and Statements||Subquery CASE and ORDER expressions|
Table EMP_ROSTER contains recent on-call hours for an employee group. Variable HOURS_WEEK is the number of hours the employee has been on-call in the past week. Variable HOURS_4WEEKS is the number of hours the employee has been on-call in the past four weeks.
EMP_ROSTER hours_ hours_ Obs id week 4weeks level 1 4GJBU 0 130 Staff 2 7SFWY 5 43 Staff 3 AT4S3 28 102 Staff 4 BGPP9 18 25 ...