|
-----Original Message-----
From: Elmaache, Hamani
Sent: September 12, 2005 11:55 AM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: summing horizontal data (by a variable) into vertical
dataset
Hi there.
If you would sum the following data by Tran_typ,
the following code can hepl:
data one ;
input acct tran_dt : mmddyy8. tran_am tran_typ $
scr opendt : mmddyy8. vip ;
format tran_dt opendt mmddyy8. ;
informat tran_dt opendt mmddyy8. ;
cards ;
123 2/3/05 24.59 otc 2 2/3/05 2
123 2/4/05 67.00 ret 2 2/3/05 2
123 2/6/05 230.50 int 2 2/3/05 2
123 2/9/05 14.75 ret 2 2/3/05 2
123 2/10/05 123.50 int 2 2/3/05 2
135 2/4/05 22.00 otc 5 11/4/04 1
135 2/4/05 78.75 ret 5 11/4/04 1
135 2/6/05 470.00 otc 5 11/4/04 1
135 2/9/05 234.25 ret 5 11/4/04 1
run ;
proc print;
run;
proc sort data=one;
by tran_typ;
data two;
do until(last.tran_typ);
set one;
by tran_typ;
count = sum(count,1 );
tran_am_sum = sum(tran_am_sum ,tran_am);
tran_am0_avg = tran_am_sum/count;
end;
run;
proc print;
run;
/**************************************/
Hamani.
On Sat, 10 Sep 2005 13:23:44 -0700, Buddhaful <buddhaful@YAHOO.COM> wrote:
>is there an array that would sum the following data by Tran_typ, &
>result in the output dataset:
>
>acct# tran_dt tran_am tran_typ scr opendt vip
>123 2/3/05 24.59 otc 2 2/3/05 2
>123 2/4/05 67.00 ret 2 2/3/05 2
>123 2/6/05 230.50 int 2 2/3/05 2
>123 2/9/05 14.75 ret 2 2/3/05 2
>123 2/10/05 123.50 int 2 2/3/05 2
>135 2/4/05 22.00 otc 5 11/4/04 1
>135 2/4/05 78.75 ret 5 11/4/04 1
>135 2/6/05 470.00 otc 5 11/4/04 1
>135 2/9/05 234.25 ret 5 11/4/04 1
>
>output:
>
>acct# Tran_otc Tran_ret Tran_int scr opendt vip
>123 24.59 81.75 354.00 2 2/4/05 2
>135 492.00 313.00 0.00 5 11/4/04 1
>
>Thanks in advance for your help...
|