Date: Wed, 17 Jul 2002 13:28:04 -0500
Reply-To: mto <mto@ADMIN4.HSC.UTH.TMC.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: mto <mto@ADMIN4.HSC.UTH.TMC.EDU>
Organization: University of Texas Health Science Center
Subject: COUNT RECORD
Content-Type: text/plain; charset=us-ascii
I have this list:
DEPT DIV ACCT INV AMT
111 AA X1 PO1 $5.00
111 AB X2 PO2 $3.00
111 AA X1 SO1 $7.00
111 AA X1 SO1 $3.00 (same invoice #)
What I need to do is a report which gives me the dept. and count how
many invoices (using the first 2 digits number) and the amount. The
result should look like:
Dept Invoce # Amount
111 PO 2 $8.00
111 SO 1 $10.00
What I did was set up the sub-string for first two-digits number:
LENGTH LEV $5.;
IF SUBSTR(INV,1,2)='PO' THEN LEV='1. PO';
ELSE IF SUBSTR(INV,1,2)='SO' THEN LEV='2.SO'; etc....
Then sort the data by DEPT,LEV. Then I used these statements:
DATA DEPT2; SET DEPT;
BY DEPT LEV INV;
RETAIN CNT TOT;
FORMAT CNT $10.;
FORMAT TOT COMMA12.2;
IF FIRST.LEV THEN DO:
CNT=0; TOT=0;
END;
CNT + 1;
TOT + AMT;
IF LAST.LEV THEN OUTPUT;
Somehow, it doesn't come out right!!!!
Any help is very much appreciated.
Mia