BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
buechler66
Barite | Level 11

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;

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

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.

buechler66
Barite | Level 11

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.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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;
buechler66
Barite | Level 11

Thanks so much for your time. 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

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 lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1259 views
  • 2 likes
  • 4 in conversation