Obtaining a Total for Each BY Group
An additional requirement of Tradewinds Travel is to
determine the number of tours that are booked with each vendor. In
order to accomplish this task, a program must group the data by a
variable. That is, the program must organize the data set into groups
of observations, with one group for each vendor. In this case, the
program must group the data by the Vendor variable. Each group is
known generically as a BY- group.
The variable that is used to determine the groupings is called a BY
variable.
In order to group the
data by the Vendor variable:
-
include a PROC SORT step to group the observations by the Vendor variable
-
use a BY statement in the DATA step
-
use a Sum statement to total the bookings ...
Get Step-by-Step Programming with Base SAS 9.4 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.