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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 682 views
  • 0 likes
  • 2 in conversation