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 (March 2010, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 4 Mar 2010 14:01:21 -0500
Reply-To:     Ya Huang <ya.huang@AMYLIN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Ya Huang <ya.huang@AMYLIN.COM>
Subject:      Re: sum by every n rows.
Comments: To: daronnebonneau@GMAIL.COM

One more way:

data need; set have (where=(mod(n,2)=0) rename=(x=x0)); set have (where=(mod(n,2)=1) rename=(x=x1)); newx=sum(x0,x1); run;

proc print; run;

Obs n x0 x1 newx

1 1 -50 -1 -51 2 3 -1 -2 -3 3 5 -1 1 0 4 7 2 3 5 5 9 -2 2 0 6 11 2 1 3 7 13 40 5 45 8 15 39 30 69

On Thu, 4 Mar 2010 00:53:44 -0800, db <daronnebonneau@GMAIL.COM> wrote:

>Hi, >Could anyone help me on summing following dataset ? >I have n, x variables and would like to calculate for sum by every 2 >rows . > >n x sum_by_every_2_rows >1 -1 >2 -50 -51 >3 -2 >4 -1 -3 >5 1 >6 -1 0 >7 3 >8 2 5 >9 2 >10 -2 0 >11 1 >12 2 3 >13 5 >14 40 45 >15 30 >16 39 69 >17 -2 -2 > >Thanks, db


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