calculate with a SUM

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

calculate with a SUM

Christine Herbst
HI!

I have usually kept my SPSS to standard syntax (eg. that which is also easily available interactively) but I have run into a problem now.

I would like to calculate with the sum of a variable - how can this be done? eg. print the value of newvar = SUM(oldvar)*2

thanks


--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
Reply | Threaded
Open this post in threaded view
|

Re: calculate with a SUM

ViAnn Beadle
Do you want to compute a sum of oldvar for all rows of data? What do you
want to do with this number?

If yes to the 1st question and you just want to print it to the output
window, then

COMPUTE newvar=oldvar * 2.
DESCRIPTIVES newvar/ statistics sum.

The COMPUTE command creates newvar which is just double the value of oldvar
for every case.
The DESCRIPTIVES command will provide the sum.

If you want something else, give us a bit more info.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Christine Herbst
Sent: Thursday, September 27, 2007 11:02 AM
To: [hidden email]
Subject: calculate with a SUM

HI!

I have usually kept my SPSS to standard syntax (eg. that which is also
easily available interactively) but I have run into a problem now.

I would like to calculate with the sum of a variable - how can this be done?
eg. print the value of newvar = SUM(oldvar)*2

thanks


--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
Reply | Threaded
Open this post in threaded view
|

R: calculate with a SUM

Luca Meyer
In reply to this post by Christine Herbst
SPSS 15 tested syntax:

data list free /oldvar.
begin data
2
3
4
5
end data.

compute temp=1.
exe.

aggregate /outfile=* mode=addvariables /break=temp /newvar=sum(oldvar).
exe.

HTH,

Luca

Mr. Luca MEYER
Market research, data analysis & more
www.lucameyer.com - Tel: +39.339.495.00.21


-----Messaggio originale-----
Da: SPSSX(r) Discussion [mailto:[hidden email]] Per conto di
Christine Herbst
Inviato: giovedì 27 settembre 2007 19.02
A: [hidden email]
Oggetto: calculate with a SUM

HI!

I have usually kept my SPSS to standard syntax (eg. that which is also
easily available interactively) but I have run into a problem now.

I would like to calculate with the sum of a variable - how can this be done?
eg. print the value of newvar = SUM(oldvar)*2

thanks


--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten Browser-Versionen
downloaden: http://www.gmx.net/de/go/browser

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.13.31/1031 - Release Date: 26/09/2007
12.12


No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.488 / Virus Database: 269.13.31/1031 - Release Date: 26/09/2007
12.12
Reply | Threaded
Open this post in threaded view
|

Re: calculate with a SUM

Maguin, Eugene
In reply to this post by Christine Herbst
Christine,

I'm confused by what you want to do.

>>I would like to calculate with the sum of a variable - how can this be
done? eg. print the value of newvar = SUM(oldvar)*2

Several things are referred to here: Print, the Sum function operating on
one variable, and a multiplication operation.

Do you know that

List newvar.

List (prints) to the ouput file the value newvar for each case?

Do you mean that newvar is twice oldvar? If so, then

Compute newvar=2*oldvar.

Is simpler even though

Compute newvar=sum(oldvar)*2.

Will probably work. I've never tried it.

Do you have something else in mind?

Gene Maguin
Reply | Threaded
Open this post in threaded view
|

Re: calculate with a SUM

Richard Ristow
In reply to this post by Christine Herbst
Checking back:
At 01:02 PM 9/27/2007, Christine Herbst wrote:

>I would like to calculate with the sum of a variable - how can this be
>done? eg. print the value of newvar = SUM(oldvar)*2

Did any of the answers posted, or anything else, ever resolve this one?

Luca Meyer's guess, that you mean the sum of the values from all cases
n the file, sounds as good as any; but it is a guess. Did that give you
what you want?

If not, when you write "SUM(oldvar)", you mean the sum of what values
of "oldvar"? Or, by any chance, something else?

-Best regards and best of luck,
  Richard