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 (April 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, 14 Apr 2009 07:03:08 -0400
Reply-To:     SAS_learner <proccontents@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SAS_learner <proccontents@GMAIL.COM>
Subject:      Re: Summing columns from two data sets
Comments: To: Sandro Saitta <sandro.saitta@gmail.com>
In-Reply-To:  <0120aa1c-c87c-4678-9d8b-11b2b232a7b8@a7g2000yqk.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1

hello sandro,

You need to merge those datasets either using Merge statement or Join them using Proc Sql and them use sum statement . As I do not how your data looks like something like

SAS Datastep Method:

Proc Sort data = a ; By <Key var>;Run; Proc Sort data = b ; By <Key var>;Run;

Data a_and_b ;

Merge a (in = _a ) b (in = _b); By <Key Var>; If b; Sum_col1_Col2 = Sum(Col1,Col2); Run;

Proc Sql Method :

Proc Sql Noprit ; Select a.key_var , B.*, Sum(col1,Col2) as Sum_col1_Col2 from a as a b as b where a.Key_Var = b.Key_Var ; Quit ;

Something like that might help

thanls SL

On Tue, Apr 14, 2009 at 6:54 AM, Sandro Saitta <sandro.saitta@gmail.com>wrote:

> Hello, > > In SAS Base, I would like to sum a column from table A with a column > from table B and put the result in table B. Both columns are numbers. > I have tried with UPDATE in a DATA step but I can't find a way to do > it. > > Does anyone have an idea? > > Kind regards. > Sandro. >


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