| Date: | Tue, 13 Oct 2009 13:59:58 -0700 |
| Reply-To: | oslo <oslo@yahoo.com> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | oslo <hokut1@YAHOO.COM> |
| Subject: | Re: Columns adding |
|
| In-Reply-To: | <200910132034.n9DFuP4w013631@malibu.cc.uga.edu> |
| Content-Type: | text/plain; charset=iso-8859-1 |
Dear Artur;
Thanks a lot. Perfect. I tried and got the results as I wanted. I appreciate for your helps
All the best,
Oslo
________________________________
From: Arthur Tabachneck <art297@NETSCAPE.NET>
To: SAS-L@LISTSERV.UGA.EDU; hokut1@YAHOO.COM
Sent: Tue, October 13, 2009 3:34:00 PM
Subject: Re: Columns adding
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
|