O'Reilly logo

Combining and Modifying SAS® Data Sets: Examples Second Edition by Michele M. Burlew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 StepPROC SQL
Featured Step Options and StatementsSubquery 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required