Example 5.6 Calculating Percentages and Statistics That One Row Contributes to a BY Group


Calculate percentages that one row contributes to a BY group. Calculate statistics for the BY group, some of which are based on how the row contributes to the statistic for the BY group. Create columns to classify and contain the results of the calculations.

Example Features

Featured StepPROC SQL
Featured Step Options and StatementsAggregate functions

CASE expression

GROUP BY clause

ORDER BY clause
Related TechniquePROC MEANS, CLASS, OUTPUT, and TYPES statements DATA step, match-merging by a value

Input Table

Table DISTRICTLEVY contains levy voting results for four towns and their precincts. Counts of voters voting for the levy are in the "YES" column. ...

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.