LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (September 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 12 Sep 2005 11:57:26 -0400
Reply-To:   "Elmaache, Hamani" <Hamani.Elmaache1@CCRA-ADRC.GC.CA>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Elmaache, Hamani" <Hamani.Elmaache1@CCRA-ADRC.GC.CA>
Subject:   Re: summing horizontal data (by a variable) into vertical dataset
Content-Type:   text/plain; charset="iso-8859-1"

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


Back to: Top of message | Previous page | Main SAS-L page