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;
PUT @1 DEPT
@11 SALESUM PD7.2;
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.