simple crossTab

Retail Revenue Distribution Analysis

Scénario de test & Cas d'usage

Business Context

A large retail chain wants to optimize its supply chain by analyzing sales performance. Instead of a simple transaction count, they need to sum the total 'MSRP' (Market Suggested Retail Price) for each combination of 'Type' (Product Category) and 'Origin' (Manufacturer Region) to identify high-value segments.
Data Preparation

Creation of a 'products' dataset simulating sales with Type, Origin, and MSRP.

Copied!
1 
2DATA casuser.products;
3call streaminit(12345);
4DO i=1 to 1000;
5IF rand('UNIFORM') > 0.5 THEN Origin='USA';
6ELSE Origin='Asia';
7IF rand('UNIFORM') > 0.3 THEN Type='Sedan';
8ELSE Type='SUV';
9MSRP = round(rand('NORMAL', 30000, 5000));
10OUTPUT;
11END;
12 
13RUN;
14 

Étapes de réalisation

1
Execute simple.crossTab to sum the MSRP by Type and Origin.
Copied!
1 
2PROC CAS;
3SIMPLE.crossTab / TABLE={name='products', caslib='casuser'} row='Type' col='Origin' weight='MSRP' aggregator='SUM';
4 
5RUN;
6 

Expected Result


A crosstabulation table where the cell values represent the total revenue (sum of MSRP) for each car type and origin, rather than the frequency of rows.