Counting

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

Counting

Tom

Hi

 

I’d like to count, how many times a certain value appears in a range of variables and write this number (the amount of the appearance of the value) in a new variable.

I couldn’t find any function in the menu – perhaps it can be done by the syntax?

 

Thanks for hints !

Tom

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Counting

Marta Garcia-Granero
Hi Tom:

Using the menu:

TRANSFORM --> COUNT VALUES WITHIN CASES (<- free translation from the Spanish version, some words might be different)

HTH,
Marta

El 22/02/2012 9:26, Balmer, Thomas escribió:

Hi

 

I’d like to count, how many times a certain value appears in a range of variables and write this number (the amount of the appearance of the value) in a new variable.

I couldn’t find any function in the menu – perhaps it can be done by the syntax?

 

Thanks for hints !

Tom

 

 


Reply | Threaded
Open this post in threaded view
|

Re: Counting

Albert-Jan Roskam
In reply to this post by Tom
Check the COUNT function ;-)
count newvar = v1 to v100 (1 thru 3).
 
Cheers!!
Albert-Jan
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, a
fresh water system, and public health, what have the Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Balmer, Thomas" <[hidden email]>
To: [hidden email]
Sent: Wednesday, February 22, 2012 9:26 AM
Subject: [SPSSX-L] Counting

Hi
 
I’d like to count, how many times a certain value appears in a range of variables and write this number (the amount of the appearance of the value) in a new variable.
I couldn’t find any function in the menu – perhaps it can be done by the syntax?
 
Thanks for hints !
Tom
 
 


Reply | Threaded
Open this post in threaded view
|

Re: Counting

John F Hall
In reply to this post by Tom

Tom

 

Marcia used the GUI:  I always use syntax, so substitute your own varname(s) and value in:

 

count <newvar> = <varlist> (<value>) .

 

There are some examples on http://surveyresearch.weebly.com/-35-derived-variables-count-and-compute.html on my website.

 

John Hall (Mr)

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

Skype:   surveyresearcher1

Phone:    (+33) (0) 2.33.45.91.47

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Balmer, Thomas
Sent: 22 February 2012 09:27
To: [hidden email]
Subject: Counting

 

Hi

 

I’d like to count, how many times a certain value appears in a range of variables and write this number (the amount of the appearance of the value) in a new variable.

I couldn’t find any function in the menu – perhaps it can be done by the syntax?

 

Thanks for hints !

Tom

 

 

Reply | Threaded
Open this post in threaded view
|

Re: Counting

John F Hall

Yes, but you have to enclose the string values in primes, eg:

 

COUNT SVAR=V1 V2 ('male ') V3 V4 V5 ('female').

 

John Hall

 

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

Skype:   surveyresearcher1

Phone:    (+33) (0) 2.33.45.91.47

 

 

 

 

From: Zhenzhen Wang [mailto:[hidden email]]
Sent: 22 February 2012 10:20
To: John F Hall
Subject: Re: Counting

 

Dear Hall,

 

Can the syntax deal with string variables?

 

Zhenzhen

2012/2/22 John F Hall <[hidden email]>

Tom

 

Marcia used the GUI:  I always use syntax, so substitute your own varname(s) and value in:

 

count <newvar> = <varlist> (<value>) .

 

There are some examples on http://surveyresearch.weebly.com/-35-derived-variables-count-and-compute.html on my website.

 

John Hall (Mr)

 

Email:     [hidden email]

Website: www.surveyresearch.weebly.com

Skype:   surveyresearcher1

Phone:    <a href="tel:%28%2B33%29%20%280%29%202.33.45.91.47" target="_blank">(+33) (0) 2.33.45.91.47

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Balmer, Thomas
Sent: 22 February 2012 09:27
To: [hidden email]
Subject: Counting

 

Hi

 

I’d like to count, how many times a certain value appears in a range of variables and write this number (the amount of the appearance of the value) in a new variable.

I couldn’t find any function in the menu – perhaps it can be done by the syntax?

 

Thanks for hints !

Tom

 

 



 

--
Department of Media and Communication
City University of Hong Kong

Reply | Threaded
Open this post in threaded view
|

Re: Counting

Melissa Ives
In reply to this post by Tom
Look at COUNT (The following counts the number of 2s in V1-3)
COUNT NewVar=V1 V2 V3 (2).

 

the ANY function may also be of interest

(any(value,var1,var2,var3)

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Balmer, Thomas
Sent: Wednesday, February 22, 2012 2:27 AM
To: [hidden email]
Subject: [SPSSX-L] Counting

 

Hi

 

I’d like to count, how many times a certain value appears in a range of variables and write this number (the amount of the appearance of the value) in a new variable.

I couldn’t find any function in the menu – perhaps it can be done by the syntax?

 

Thanks for hints !

Tom

 

 



PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.
Reply | Threaded
Open this post in threaded view
|

Re: Counting

David Marso
Administrator
AFAIK: ANY is a "logical" function returning either a 0 or a 1.
0 is value is NOT found in the list, 1 if it IS found.
--
Melissa Ives wrote
Look at COUNT (The following counts the number of 2s in V1-3)

COUNT NewVar=V1 V2 V3 (2).

the ANY function may also be of interest
(any(value,var1,var2,var3)

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Balmer, Thomas
Sent: Wednesday, February 22, 2012 2:27 AM
To: [hidden email]
Subject: [SPSSX-L] Counting

Hi

I'd like to count, how many times a certain value appears in a range of variables and write this number (the amount of the appearance of the value) in a new variable.
I couldn't find any function in the menu - perhaps it can be done by the syntax?

Thanks for hints !
Tom



________________________________
PRIVILEGED AND CONFIDENTIAL INFORMATION
This transmittal and any attachments may contain PRIVILEGED AND
CONFIDENTIAL information and is intended only for the use of the
addressee. If you are not the designated recipient, or an employee
or agent authorized to deliver such transmittals to the designated
recipient, you are hereby notified that any dissemination,
copying or publication of this transmittal is strictly prohibited. If
you have received this transmittal in error, please notify us
immediately by replying to the sender and delete this copy from your
system. You may also call us at (309) 827-6026 for assistance.
Please reply to the list and not to my personal email.
Those desiring my consulting or training services please feel free to email me.
---
"Nolite dare sanctum canibus neque mittatis margaritas vestras ante porcos ne forte conculcent eas pedibus suis."
Cum es damnatorum possederunt porcos iens ut salire off sanguinum cliff in abyssum?"