BookmarkSubscribeRSS Feed
KevinC_
Fluorite | Level 6
Hello,

I am trying to use proc means to find the sum for sales amount for each dept. The problem is each dept couuld be listed more than once with different sales amount. I want to cound all of the 'duplicate' dept because that's how the data come in.

But the report is showing the sum for each 'duplicate' dept. I would like to see one combined sum for all duplicate dept. Can i do this with proc means?

PROC MEANS MAXDEC=2 SUM NOPRINT; BY DEPT; VAR SALEAMT;
OUTPUT OUT=C SUM = SALESUM;
DATA D; SET C;
FILE OUT;
PUT @1 DEPT
@11 SALESUM PD7.2;

Help Please ... Thank you
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
From what I understand, you want to "count" (do you mean combine together as one DEPT (DEPT='*DUPS*'; )???

Regardless, I believe you will need to pre-process your data file with a DATA step, as follows:

1) sort SAS member input by DEPT, creating a temp file.
2) use DATA step to input/output the temp file, and use FIRST.DEPT and LAST.DEPT to determine where there are multiples, and do something -- either combine these into a single DEPT value or establish a new "count" variable).
3) sort your temp file in DEPT sequence.
4) Use PROC MEANS, as you have shown in your code.

Scott Barry
SBBWorks, Inc.
KevinC_
Fluorite | Level 6
sbb, thanks for your reply. yes, that was 'count'... sorry
I meant 'include' all duplicate dept so that each dept would show up only once with one total in the report

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 811 views
  • 0 likes
  • 2 in conversation