I have the following code:
There are over 50 unique observations in the "type" variable and I'm hoping that someone can have a bit of code that will do this based on the observations as they may vary from month to month (some months there will be 40 and others 40 to 50).
proc summary data=work.old_data nway;
class suburb type;
var customers ;
output out=work.new_data sum= ;
run;
Mock Data | |||||
Suburb | Type | Customers | |||
Suburb1 | Type1 | 50 | |||
Suburb1 | Type2 | 100 | |||
Suburb1 | Type3 | 2 | |||
Suburb1 | Type4 | 3000 | |||
Suburb1 | Type5 | 250 | |||
Suburb2 | Type1 | 25 | |||
Suburb2 | Type2 | 35 | |||
Suburb2 | Type3 | 7500 | |||
Suburb2 | Type4 | 1 | |||
Suburb2 | Type5 | 5 | |||
Desired Result | |||||
Suburb | Type1 | Type2 | Type3 | Type4 | Type5 |
Suburb1 | 50 | 100 | 2 | 3000 | 250 |
Suburb2 | 25 | 35 | 7500 | 1 | 5 |
proc report data=have; column suburb customers,type; define suburb / group; define customers / "" analysis sum; define type / "" across; run;
proc report data=have; column suburb customers,type; define suburb / group; define customers / "" analysis sum; define type / "" across; run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.
Find more tutorials on the SAS Users YouTube channel.