Some questions about the operations on spss data using syntax

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

Some questions about the operations on spss data using syntax

张新张
Hi List,

I want to do some operations with spss data with the syntax, but I
don't how to implement.
1. How to get the total case number using syntax?
2. How to plus all the values of a variable using syntax?

Thanks for your instructions!

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Automatic reply: Some questions about the operations on spss data using syntax

Harmon, Judith, PED

I will be out of the office on Monday, April 30th. If you have questions about the ADE system, please call Craig at 1-800-334-1918.   Any other questions, please contact Dan Hall, at 331-0415.  Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

John F Hall
In reply to this post by 张新张
You need to be more specific, but have a look at the syntax-based SPSS
tutorials on my website, especially Block 1 "Analysing one variable".


John F Hall (Mr)

Email:    [hidden email]
Website: www.surveyresearch.weebly.com





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of ???
Sent: 28 April 2012 09:43
To: [hidden email]
Subject: Some questions about the operations on spss data using syntax

Hi List,

I want to do some operations with spss data with the syntax, but I don't how
to implement.
1. How to get the total case number using syntax?
2. How to plus all the values of a variable using syntax?

Thanks for your instructions!

=====================
To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.
UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the
list, send the command SIGNOFF SPSSX-L For a list of commands to manage
subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

Art Kendall
In reply to this post by 张新张
Like all kinds of writing,� creating sets of syntax is an iterative process.� Even over short periods of time the writer becomes more skilled , rethinks what (s)he wants to do, and rethinks how to do it.� One way to get a first draft is to use the menus and exit via <paste>. Then hover your cursor over a command and click <f1>. This brings up the help for that command.� This tells you what the options are.� You can then tune the syntax to do what you want.

There is very extensive information under <help> in the long run it is very helpful to use the tutorials, case studies, syntax, and later possibly get into the algorithms.

Do you already have the data in an SPSS system file?
Is the "variables view" filled invariable names, variable labels, value labels including missing value labels, missing values, and printing format?
[SPSS will run without all of the labels.� However, in the long run it is beneficial for you to understand what your data means before you start manipulating it.]

If so, click <analyze> <descriptive statistics> <frequencies>.
Then fill in the choices with your specifics.
Exit the menu via <paste>.
Hover your cursor over "frequencies". Click <f1>.
When you are satisfied with your instructions to the program, highlight the syntax, and click the icon with a green triangle pointing to the right.

Inspect the output.� Go back to your data and fix labels, locate cases with suspicious (i.e., funny-looking) values, etc.

This seems a little tedious but using a procedure like this will help you develop a good understanding of what you are doing.

P.S. In your post, I guessed the word "plus" to mean "show".
Art Kendall
Social Research Consultants

On 4/28/2012 3:43 AM, � 新� wrote:
Hi List,

I want to do some operations with spss data with the syntax, but I
don't how to implement.
1. How to get the total case number using syntax?
2. How to plus all the values of a variable using syntax?

Thanks for your instructions!

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

John F Hall

Art

 

I suspect “plus” means “add all together” as in

 

Compute x = sum.n (y1 to yn).

 

John

 

John F Hall (Mr)

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

 

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Art Kendall
Sent: 28 April 2012 13:38
To: [hidden email]
Subject: Re: Some questions about the operations on spss data using syntax

 

Like all kinds of writing,  creating sets of syntax is an iterative process.  Even over short periods of time the writer becomes more skilled , rethinks what (s)he wants to do, and rethinks how to do it.  One way to get a first draft is to use the menus and exit via <paste>. Then hover your cursor over a command and click <f1>. This brings up the help for that command.  This tells you what the options are.  You can then tune the syntax to do what you want.

There is very extensive information under <help> in the long run it is very helpful to use the tutorials, case studies, syntax, and later possibly get into the algorithms.

Do you already have the data in an SPSS system file?
Is the "variables view" filled invariable names, variable labels, value labels including missing value labels, missing values, and printing format?
[SPSS will run without all of the labels.  However, in the long run it is beneficial for you to understand what your data means before you start manipulating it.]

If so, click <analyze> <descriptive statistics> <frequencies>.
Then fill in the choices with your specifics.
Exit the menu via <paste>.
Hover your cursor over "frequencies". Click <f1>.
When you are satisfied with your instructions to the program, highlight the syntax, and click the icon with a green triangle pointing to the right.

Inspect the output.  Go back to your data and fix labels, locate cases with suspicious (i.e., funny-looking) values, etc.

This seems a little tedious but using a procedure like this will help you develop a good understanding of what you are doing.

P.S. In your post, I guessed the word "plus" to mean "show".

Art Kendall
Social Research Consultants


On 4/28/2012 3:43 AM, 张新张 wrote:

Hi List,
 
I want to do some operations with spss data with the syntax, but I
don't how to implement.
1. How to get the total case number using syntax?
2. How to plus all the values of a variable using syntax?
 
Thanks for your instructions!
 
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
 

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

Art Kendall
I see. Sounds plausible.

Might also mean sum across cases too.

Art Kendall
Social Research Consultants

On 4/28/2012 8:08 AM, John F Hall wrote:

Art

I suspect “plus” means “add all together” as in

Compute x = sum.n (y1 to yn).

John

John F Hall (Mr)

Email: � � � [hidden email]

Website: www.surveyresearch.weebly.com

From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Art Kendall
Sent: 28 April 2012 13:38
To: [hidden email]
Subject: Re: Some questions about the operations on spss data using syntax

Like all kinds of writing,� creating sets of syntax is an iterative process.� Even over short periods of time the writer becomes more skilled , rethinks what (s)he wants to do, and rethinks how to do it.� One way to get a first draft is to use the menus and exit via <paste>. Then hover your cursor over a command and click <f1>. This brings up the help for that command.� This tells you what the options are.� You can then tune the syntax to do what you want.

There is very extensive information under <help> in the long run it is very helpful to use the tutorials, case studies, syntax, and later possibly get into the algorithms.

Do you already have the data in an SPSS system file?
Is the "variables view" filled invariable names, variable labels, value labels including missing value labels, missing values, and printing format?
[SPSS will run without all of the labels.� However, in the long run it is beneficial for you to understand what your data means before you start manipulating it.]

If so, click <analyze> <descriptive statistics> <frequencies>.
Then fill in the choices with your specifics.
Exit the menu via <paste>.
Hover your cursor over "frequencies". Click <f1>.
When you are satisfied with your instructions to the program, highlight the syntax, and click the icon with a green triangle pointing to the right.

Inspect the output.� Go back to your data and fix labels, locate cases with suspicious (i.e., funny-looking) values, etc.

This seems a little tedious but using a procedure like this will help you develop a good understanding of what you are doing.

P.S. In your post, I guessed the word "plus" to mean "show".

Art Kendall
Social Research Consultants


On 4/28/2012 3:43 AM, � 新� wrote:

Hi List,
I want to do some operations with spss data with the syntax, but I
don't how to implement.
1. How to get the total case number using syntax?
2. How to plus all the values of a variable using syntax?
Thanks for your instructions!
=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

Bruce Weaver
Administrator
In reply to this post by 张新张
It sounds like you want the AGGREGATE command--look it up in the syntax manual, where you should find some examples.  I don't have SPSS on this machine, but I think you want something like:

AGGREGATE
  /OUTFILE=* MODE=ADDVARIABLES
  /BREAK=
  /NoCases=NU
  /SumX=SUM(X)
.

HTH.


张新张 wrote
Hi List,

I want to do some operations with spss data with the syntax, but I
don't how to implement.
1. How to get the total case number using syntax?
2. How to plus all the values of a variable using syntax?

Thanks for your instructions!

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

张新张
In reply to this post by John F Hall
First, thanks for your instructions. Here, I add more details to make
my question clear, and take the SUM question as the example. In fact,
I want to get the sum value of a variable,  save the value to a
constant (not a dataset variable), and the constant can be used for
successive operations. I hope the syntax running as follows.
1. Filter out the sum value of a variable VAR1.
2. Constant N = sum of VAR1
3. Do other operations using N, such as VAR2=VAR1/N.
Could I implement this using spss syntax? Thanks a lot.

2012/4/28 John F Hall <[hidden email]>:

> You need to be more specific, but have a look at the syntax-based SPSS
> tutorials on my website, especially Block 1 "Analysing one variable".
>
>
> John F Hall (Mr)
>
> Email:    [hidden email]
> Website: www.surveyresearch.weebly.com
>
>
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of ???
> Sent: 28 April 2012 09:43
> To: [hidden email]
> Subject: Some questions about the operations on spss data using syntax
>
> Hi List,
>
> I want to do some operations with spss data with the syntax, but I don't how
> to implement.
> 1. How to get the total case number using syntax?
> 2. How to plus all the values of a variable using syntax?
>
> Thanks for your instructions!
>
> =====================
> To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.
> UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the
> list, send the command SIGNOFF SPSSX-L For a list of commands to manage
> subscriptions, send the command INFO REFCARD
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

Bruce Weaver
Administrator
There are no constants in ordinary SPSS syntax, but for the example you give, a variable with the same value on every case will do the trick.  Therefore, I repeat my earlier advice, which was given here:

http://spssx-discussion.1045642.n5.nabble.com/Some-questions-about-the-operations-on-spss-data-using-syntax-tp5672245p5672540.html


张新张 wrote
First, thanks for your instructions. Here, I add more details to make
my question clear, and take the SUM question as the example. In fact,
I want to get the sum value of a variable,  save the value to a
constant (not a dataset variable), and the constant can be used for
successive operations. I hope the syntax running as follows.
1. Filter out the sum value of a variable VAR1.
2. Constant N = sum of VAR1
3. Do other operations using N, such as VAR2=VAR1/N.
Could I implement this using spss syntax? Thanks a lot.

2012/4/28 John F Hall <[hidden email]>:
> You need to be more specific, but have a look at the syntax-based SPSS
> tutorials on my website, especially Block 1 "Analysing one variable".
>
>
> John F Hall (Mr)
>
> Email:    [hidden email]
> Website: www.surveyresearch.weebly.com
>
>
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of ???
> Sent: 28 April 2012 09:43
> To: [hidden email]
> Subject: Some questions about the operations on spss data using syntax
>
> Hi List,
>
> I want to do some operations with spss data with the syntax, but I don't how
> to implement.
> 1. How to get the total case number using syntax?
> 2. How to plus all the values of a variable using syntax?
>
> Thanks for your instructions!
>
> =====================
> To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.
> UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the
> list, send the command SIGNOFF SPSSX-L For a list of commands to manage
> subscriptions, send the command INFO REFCARD
>

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).
Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

la volta statistics
In reply to this post by 张新张
Hi the following code my do what you want.
Hope this helps, Christian

DATA LIST LIST /var1(F8).
BEGIN DATA.
10
15
10
20
25
15
25
END DATA.

* LIST.

COMPUTE break_v = 1.

AGGREGATE
   /OUTFILE=*
   MODE=ADDVARIABLES
   /BREAK=break_v
   /var1_sum = SUM(var1).

DO IF $Casenum = 1.
WRITE OUTFILE 'c:\temp\temp_Makro.sps' /"DEFINE
!sum_tot()"/var1_sum/"!ENDDEFINE.".
End if.

INCLUDE 'c:\temp\temp_Makro.sps'.

COMPUTE var2 =!sum_tot + Var1.
Exec.

* Clean up.
Erase File = 'c:\temp\temp.sps'.



**********************************
la volta statistics
Christian Schmidhauser, Dr.phil.II
Weinbergstrasse 108
CH-8006 Zürich
Tel: +41 (043) 233 98 01
Fax: +41 (043) 233 98 02
email: mailto:[hidden email]
Web: www.lavolta.ch





On Wed, 2 May 2012 23:20:48 +0800
  � 新�  <[hidden email]> wrote:

>First, thanks for your instructions. Here, I add more details to make
> my question clear, and take the SUM question as the example. In
>fact,
> I want to get the sum value of a variable,  save the value to a
> constant (not a dataset variable), and the constant can be used for
> successive operations. I hope the syntax running as follows.
> 1. Filter out the sum value of a variable VAR1.
> 2. Constant N = sum of VAR1
> 3. Do other operations using N, such as VAR2=VAR1/N.
> Could I implement this using spss syntax? Thanks a lot.
>
> 2012/4/28 John F Hall <[hidden email]>:
>> You need to be more specific, but have a look at the syntax-based
>>SPSS
>> tutorials on my website, especially Block 1 "Analysing one
>>variable".
>>
>>
>> John F Hall (Mr)
>>
>> Email:    [hidden email]
>> Website: www.surveyresearch.weebly.com
>>
>>
>>
>>
>>
>> -----Original Message-----
>> From: SPSSX(r) Discussion [mailto:[hidden email]] On
>>Behalf Of ???
>> Sent: 28 April 2012 09:43
>> To: [hidden email]
>> Subject: Some questions about the operations on spss data using
>>syntax
>>
>> Hi List,
>>
>> I want to do some operations with spss data with the syntax, but I
>>don't how
>> to implement.
>> 1. How to get the total case number using syntax?
>> 2. How to plus all the values of a variable using syntax?
>>
>> Thanks for your instructions!
>>
>> =====================
>> To manage your subscription to SPSSX-L, send a message to
>>LISTSERV@LISTSERV.
>> UGA.EDU (not to SPSSX-L), with no body text except the command. To
>>leave the
>> list, send the command SIGNOFF SPSSX-L For a list of commands to
>>manage
>> subscriptions, send the command INFO REFCARD
>>
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> [hidden email] (not to SPSSX-L), with no body text except
>the
> command. To leave the list, send the command
> SIGNOFF SPSSX-L
>For a list of commands to manage subscriptions, send the command
> INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Some questions about the operations on spss data using syntax

Art Kendall
In reply to this post by Bruce Weaver
As Bruce said
AGGREGATE
� /OUTFILE=* MODE=ADDVARIABLES
� /BREAK=
� /NoCases=NU
� /SumX=SUM(X)
then
compute newvar = X/SumX.
Art Kendall
Social Research Consultants

On 5/2/2012 12:00 PM, Bruce Weaver wrote:
There are no constants in ordinary SPSS syntax, but for the example you give,
a variable with the same value on every case will do the trick.  Therefore,
I repeat my earlier advice, which was given here:

http://spssx-discussion.1045642.n5.nabble.com/Some-questions-about-the-operations-on-spss-data-using-syntax-tp5672245p5672540.html



� 新�  wrote
First, thanks for your instructions. Here, I add more details to make
my question clear, and take the SUM question as the example. In fact,
I want to get the sum value of a variable,  save the value to a
constant (not a dataset variable), and the constant can be used for
successive operations. I hope the syntax running as follows.
1. Filter out the sum value of a variable VAR1.
2. Constant N = sum of VAR1
3. Do other operations using N, such as VAR2=VAR1/N.
Could I implement this using spss syntax? Thanks a lot.

2012/4/28 John F Hall &lt;johnfhall@&gt;:
You need to be more specific, but have a look at the syntax-based SPSS
tutorials on my website, especially Block 1 "Analysing one variable".


John F Hall (Mr)

Email:    johnfhall@
Website: www.surveyresearch.weebly.com





-----Original Message-----
From: SPSSX(r) Discussion [[hidden email]] On Behalf Of ???
Sent: 28 April 2012 09:43
To: [hidden email]
Subject: Some questions about the operations on spss data using syntax

Hi List,

I want to do some operations with spss data with the syntax, but I don't
how
to implement.
1. How to get the total case number using syntax?
2. How to plus all the values of a variable using syntax?

Thanks for your instructions!

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.
UGA.EDU (not to SPSSX-L), with no body text except the command. To leave
the
list, send the command SIGNOFF SPSSX-L For a list of commands to manage
subscriptions, send the command INFO REFCARD

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD


-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.

--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Some-questions-about-the-operations-on-spss-data-using-syntax-tp5672245p5680930.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD
Art Kendall
Social Research Consultants