Output 6.13 Sample Input Table for Summarizing Data from Multiple Columns
You want to create output that shows the total sales for each month and the total sales for
all three months.
Use the following PROC SQL code to produce the monthly totals and grand total:
title 'Total First Quarter Sales';
select sum(January) as JanTotal,
sum(February) as FebTotal,
sum(March) as MarTotal,
sum(calculated JanTotal, calculated FebTotal,
calculated MarTotal) as GrandTotal format=dollar10.
Output 6.14 PROC SQL Output for Summarizing Data from Multiple Columns
How It Works
Recall that when you specify one column as the argument to an aggregate function, the
values in that column are calculated. When you specify multiple columns, the values in
each row of the columns are calculated. This solution uses the SUM function to calculate
Summarizing Data in Multiple Columns 193