Example 8.6 Creating a Customized Sort Order without Adding a New Column to the Table
Goal
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.
Example Features
Featured Step | PROC SQL |
Featured Step Options and Statements | Subquery CASE and ORDER expressions |
Input Table
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 ...
Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.