Date: Tue, 3 Feb 1998 14:59:51 -0800
Reply-To: Steve <Steve@ADDER.DEMON.COSPAMSPAMSPAM.UK>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Steve <Steve@ADDER.DEMON.COSPAMSPAMSPAM.UK>
Organization: <none>
Subject: Re: How to sum a column? (Please look at my code, thanks)
Content-Type: text/plain; charset=us-ascii
Louise Lawson wrote:
>
> Hi Tang.
>
> If you want a new dataset that has one observation with the sum of
> the column in it, use this code:
>
> proc summary data=one;
> var x;
> output out=sumofone sum=sumofx;
> RUN;
>
Also look into PROC SQL. It's a wonderful data manipulation tool.
In your case you could use something like:
proc sql;
create table sumofone as select sum(x) as sumofx from one;
With this you can easily merge it back with the original data (eg to
then take differences etc) and/or easily create macro variables.
With more complex SQL though it's easy to not notice if it's not quite
doing what you want and this may be a problem for a beginner.
Steve