In daily data processing, it is very common to need to switch from a "transactional" level of detail (multiple rows per customer) to a "summary" level (one row per customer with a total).
1. The Problem: Summing balances by customer
The user has a dataset containing customer numbers, dates, and amounts (balances). The same customer (Cust_1) appears multiple times on different dates.
Customer
Amount
Date
Cust_1
100.00
01/01/2008
Cust_1
150.00
10/01/2008
Cust_1
125.00
11/01/2008
Objective:
Create a new table containing the sum of the amounts for each customer.
Expected result for Cust_1: 375.00
Note : In the original discussion, an effective solution using PROC REPORT was provided. Although often used for display (printing), this procedure is very powerful for generating output tables.
proc report data=cust nowd out=temp;
column cust_no bal;
define cust_no / group noprint;
define bal / analysis sum noprint;
run;
The codes and examples provided on WeAreCAS.eu are for educational purposes. It is imperative not to blindly copy-paste them into your production environments. The best approach is to understand the logic before applying it. We strongly recommend testing these scripts in a test environment (Sandbox/Dev). WeAreCAS accepts no responsibility for any impact or data loss on your systems.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.