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 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 15 Mar 2006 09:46:07 -0600
Reply-To:     Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jiann-Shiun Huang <Jiann-Shiun.Huang@AMERUS.COM>
Subject:      Re: Sum a column
Comments: To: rjo.cebr@CBS.DK
Content-Type: text/plain; charset=US-ASCII

Here is an implementation and the output follows the code. data temp; input id $ empl; datalines; 1 1 2 1 3 2 4 2 5 1 ; run;

proc sql; create table Result as select *, sum(empl) as sum from temp; quit;

proc print data=Result noobs; run;

***** Output ***** The SAS System 08:45 Tuesday, March 14, 2006 218

id empl sum

1 1 7 2 1 7 3 2 7 4 2 7 5 1 7

J S Huang 1-515-557-3987 fax 1-515-557-2422

>>> RasmusJo <rjo.cebr@CBS.DK> 3/15/2006 9:22:42 AM >>> Hi comp.soft-sys.sas,

I'm having a brain melt-down as I try to sum a column/variable.

My problem is that I would like to sum the variables empl, see below:

id empl 1 1 2 1 3 2 4 2 5 1

such that I get the variable 'sum'

id empl sum 1 1 7 2 1 7 3 2 7 4 2 7 5 1 7

So far I only managed to create an accumulating variable whose value is 7 for the last observation.However, I would like to create a variable that is 7 for all observations.

Can anyone help`?

Thanks, Rasmus


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