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 (October 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 13 Oct 2009 16:33:59 -0400
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: Columns adding
Comments: To: hokut1@YAHOO.COM
Content-Type: text/plain; charset=ISO-8859-1

Oslo,

One way would be to use arrays. E.g.,:

data want (keep=total:); set a; array adata(*) a1-a300; array bdata(*) b1-b300; array cdata(*) c1-c300; array total(300); do i=1 to 300; total(i)=sum(adata(i),bdata(i),cdata(i)); end; run;

HTH, Art -------- On Tue, 13 Oct 2009 13:11:49 -0700, oslo <hokut1@YAHOO.COM> wrote:

>Dear Users; � Suppose I have a data set with 900 columns as follows. � data a; input a1-a300 b1-b300 c1-c300; cards; ............................................... So would like create a data set that has 300 columns. That is I need to sum all columns as a1+b1+c1�=first column of new data set a2+b2+c2=second column of new data set a3+b3+c3=Third column of new data set ... .... and so on. Is there any practical way to do that. � Thanks in advance, � Oslo


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