Date: Tue, 23 Jun 2009 07:06:06 -0700 "Richard A. DeVenezia" "SAS(r) Discussion" "Richard A. DeVenezia" http://groups.google.com Re: datasets sum To: sas-l@uga.edu text/plain; charset=ISO-8859-1

On Jun 23, 9:43 am, zainab hassan <zainabfaizhas...@gmail.com> wrote: > i have a simple question but i am not sure how to implement in SAS > > i have lets say 20 datasets, namely a,b,c....etc. Each dataset has a > total column > > I want to create a dataset called temp that extracts the total column > from each dataset and adds it to the other. So basically I am adding > the total column from a to b and so on. The final total column should > be stored in temp.

Presuming each table has M rows and each row I of "temp" is the grand total across the totals in row I of tables "a" ... "t".

Here is one way. There are numerous other ways to do it.

data a b c d e f g h i j k l m n o p q r s t; do row = 1 to 100; total = row; output; end; run;

data temp; set a; temp + total; set b; temp + total; set c; temp + total; set d; temp + total; set e; temp + total; set f; temp + total; set g; temp + total; set h; temp + total; set i; temp + total; set j; temp + total; set k; temp + total; set l; temp + total; set m; temp + total; set n; temp + total; set o; temp + total; set p; temp + total; set q; temp + total; set r; temp + total; set s; temp + total; set t; temp + total; keep temp; run;

-- Richard A. DeVenezia http://www.devenezia.com

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