Example 9.6 Sorting Variable Values within an Observation


Sort a series of character variable values and a series of numeric variable values within an observation.

Example Features

Featured StepDATA step
Featured Step Options and StatementsCALL SORTC and CALL SORTN CALL routines LARGEST, ORDINAL, and SMALLEST functions
Related TechniqueDATA step and ORDINAL function: ORDINAL sort in descending order

Input Data Set

Data set ADSURVEY contains responses from five partipants in a survey for a store. The three character variables NOTICED1, NOTICED2, and NOTICED3 list where the respondent saw an ad. The three numeric variables AMOUNT1, AMOUNT2, and AMOUNT3 are the amounts spent (if positive) or refunded (if negative) as recalled by the respondent ...

Get Combining and Modifying SAS® Data Sets: Examples Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.