Hi. I need the individual all_volume for each region. Currently I run this in 3 different data steps (see below). I'm wondering if there's a Proc I could us instead? And if you could help with the syntax for it? Thanks.
proc sql;
create table Want as
select sum(a_volume+b_volume+c_volume) AS all_volume
from Have
where region = '1'
;quit;
proc sql;
create table Want as
select sum(a_volume+b_volume+c_volume) AS all_volume
from Have
where region = '2'
;quit;
proc sql;
create table Want as
select sum(a_volume+b_volume+c_volume) AS all_volume
from Have
where region = '3'
;quit;
Do not split data. SAS is based on the by group principal. One dataset with groups of data, so:
proc sql;
create table want as
select region,
sum(a_volume+b_volume+c_volume) as all_volume
from have
group by region;
quit;
So you want a separate data set for each unique value of region, correct? There are several ways to do this, but my first question is: Why?
It is rarely a good idea to split a data set like this. Instead use By-Group processing on the original data set.
No, sorry I wasn't more clear on that. I'm just plugging them into a spreadsheet so a single output is ideal. Sorry again.
Do not split data. SAS is based on the by group principal. One dataset with groups of data, so:
proc sql;
create table want as
select region,
sum(a_volume+b_volume+c_volume) as all_volume
from have
group by region;
quit;
Thanks so much for your time.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.