Processing Logic for Equivalencies or Straights in SPSS

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

Processing Logic for Equivalencies or Straights in SPSS

David B. Nolle-2
Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

Jon K Peck
Although your first syntax is valid, it does not mean what you think it does.
compute agrees = x=y=z
for example, is evaluated as
(x=y) = z.
If x = y, the result is true (1), so the second
part evaluates as
1 = z.
If x ne y, the x=y expression evaluates as false (0), so the second test is
0 = z.

HTH,

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        "David B. Nolle" <[hidden email]>
To:        [hidden email]
Date:        10/10/2011 08:46 AM
Subject:        [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

Maguin, Eugene
Jon, I'm extremely surprised that the expression is syntacticlly correct. After i saw your message, i looked at the IF help file and there is nothing there that suggests to me that the expression is correct. Maybe i'm not understanding the documentation correctly but why would the syntax checker accept statements that are not correct according to the documentation? I've noticed this before, especially when Ray was actively posting, and i wrote it off as my being too rigid in reading the documentation. Am i or are there 'secret' layers to spss?
 
Gene Maguin


From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Jon K Peck
Sent: Monday, October 10, 2011 10:55 AM
To: [hidden email]
Subject: Re: Processing Logic for Equivalencies or Straights in SPSS

Although your first syntax is valid, it does not mean what you think it does.
compute agrees = x=y=z
for example, is evaluated as
(x=y) = z.
If x = y, the result is true (1), so the second
part evaluates as
1 = z.
If x ne y, the x=y expression evaluates as false (0), so the second test is
0 = z.

HTH,

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        "David B. Nolle" <[hidden email]>
To:        [hidden email]
Date:        10/10/2011 08:46 AM
Subject:        [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

Jon K Peck
The statement is syntactically correct. The equality operator binds the expression on both sides and evaluates to a true/false outcome, which is then input to the next expression.  Evaluation proceeds left to right.
(a=b) = c
(which is the same as a=b=c or a eq b eq c)
means
1. evaluate a=b yielding 0 or 1
2. evaluate that outcome against c.

HTH,

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        Gene Maguin <[hidden email]>
To:        [hidden email]
Date:        10/10/2011 09:14 AM
Subject:        Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in              SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Jon, I'm extremely surprised that the expression is syntacticlly correct. After i saw your message, i looked at the IF help file and there is nothing there that suggests to me that the expression is correct. Maybe i'm not understanding the documentation correctly but why would the syntax checker accept statements that are not correct according to the documentation? I've noticed this before, especially when Ray was actively posting, and i wrote it off as my being too rigid in reading the documentation. Am i or are there 'secret' layers to spss?
 
Gene Maguin


From: SPSSX(r) Discussion [[hidden email]] On Behalf Of Jon K Peck
Sent:
Monday, October 10, 2011 10:55 AM
To:
[hidden email]
Subject:
Re: Processing Logic for Equivalencies or Straights in SPSS


Although your first syntax is valid, it does not mean what you think it does.
compute agrees = x=y=z

for example, is evaluated as

(x=y) = z.

If x = y, the result is true (1), so the second
part evaluates as

1 = z.

If x ne y, the x=y expression evaluates as false (0), so the second test is

0 = z.


HTH,


Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621





From:        
"David B. Nolle" <[hidden email]>
To:        
[hidden email]
Date:        
10/10/2011 08:46 AM
Subject:        
[SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS
Sent by:        
"SPSSX(r) Discussion" <[hidden email]>




Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

Art Kendall
In reply to this post by David B. Nolle-2
Jon answered why your syntax should have been more like
compute straight = VAR1 EQ VAR2 AND VAR2 EQ VAR3 AND VAR3 EQ VAR4 ...

However.
compute straight = sd(var1 to var6) eq 0. 

should also work.

Art Kendall
Social Research Consultants

On 10/10/2011 10:45 AM, David B. Nolle wrote:
Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

David B. Nolle-2
In reply to this post by Jon K Peck
Jon,
 
Thank you for your prompt expert advice.
 
I now see why my first syntax identified no cases of straights involving, for example, all 2's or all 3's or all 4's (which are actually present in the test file). Moreover, I now see why the pattern of 2,2,1,1,1,1 (across the six variables) was successful: Because the first two values are true (which equals 1) and the remaining values are all 1's, SPSS evaluates all of the equivalencies as true.
 
David   
----- Original Message -----
Sent: Monday, October 10, 2011 10:55 AM
Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

Although your first syntax is valid, it does not mean what you think it does.
compute agrees = x=y=z
for example, is evaluated as
(x=y) = z.
If x = y, the result is true (1), so the second
part evaluates as
1 = z.
If x ne y, the x=y expression evaluates as false (0), so the second test is
0 = z.

HTH,

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        "David B. Nolle" <[hidden email]>
To:        [hidden email]
Date:        10/10/2011 08:46 AM
Subject:        [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

David B. Nolle-2
In reply to this post by Art Kendall
Art,
 
Thank you for seconding Jon's explanation and for the alternative (parsimonious) syntax which does indeed identify the correct 67 cases. 
 
David 
----- Original Message -----
Sent: Monday, October 10, 2011 11:28 AM
Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

Jon answered why your syntax should have been more like
compute straight = VAR1 EQ VAR2 AND VAR2 EQ VAR3 AND VAR3 EQ VAR4 ...

However.
compute straight = sd(var1 to var6) eq 0. 

should also work.

Art Kendall
Social Research Consultants

On 10/10/2011 10:45 AM, David B. Nolle wrote:
Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

Art Kendall
You're welcome.

Art


On 10/10/2011 12:31 PM, David B. Nolle wrote:
Art,
 
Thank you for seconding Jon's explanation and for the alternative (parsimonious) syntax which does indeed identify the correct 67 cases. 
 
David 
----- Original Message -----
Sent: Monday, October 10, 2011 11:28 AM
Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

Jon answered why your syntax should have been more like
compute straight = VAR1 EQ VAR2 AND VAR2 EQ VAR3 AND VAR3 EQ VAR4 ...

However.
compute straight = sd(var1 to var6) eq 0. 

should also work.

Art Kendall
Social Research Consultants

On 10/10/2011 10:45 AM, David B. Nolle wrote:
Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

Melissa Ives
In reply to this post by David B. Nolle-2

Wouldn’t it also work to say

Compute straight=(max.6(v1 to v6)=min.6(v1 to v6).

 

?

Melissa

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David B. Nolle
Sent: Monday, October 10, 2011 10:59 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

 

Jon,

 

Thank you for your prompt expert advice.

 

I now see why my first syntax identified no cases of straights involving, for example, all 2's or all 3's or all 4's (which are actually present in the test file). Moreover, I now see why the pattern of 2,2,1,1,1,1 (across the six variables) was successful: Because the first two values are true (which equals 1) and the remaining values are all 1's, SPSS evaluates all of the equivalencies as true.

 

David   

----- Original Message -----

Sent: Monday, October 10, 2011 10:55 AM

Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

 

Although your first syntax is valid, it does not mean what you think it does.
compute agrees = x=y=z
for example, is evaluated as
(x=y) = z.
If x = y, the result is true (1), so the second
part evaluates as
1 = z.
If x ne y, the x=y expression evaluates as false (0), so the second test is
0 = z.

HTH,

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        "David B. Nolle" <[hidden email]>
To:        [hidden email]
Date:        10/10/2011 08:46 AM
Subject:        [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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



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: Processing Logic for Equivalencies or Straights in SPSS

John F Hall
In reply to this post by David B. Nolle-2

David

 

If you want to identify which value(s) the straights are in which case, try (untested):

 

compute serial = $casenum.

do repeat.

Y = 1 to 6.

/Z = straight1 to straight6.

count z = var1 to var6 (y).

count straights = straight1 to strait6 (6).

end repeat.

temp.

select if straights eq 6.

list serial straight1 to straight6.

 

 

John F Hall

 

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David B. Nolle
Sent: 10 October 2011 18:31
To: [hidden email]
Subject: Re: Processing Logic for Equivalencies or Straights in SPSS

 

Art,

 

Thank you for seconding Jon's explanation and for the alternative (parsimonious) syntax which does indeed identify the correct 67 cases. 

 

David 

----- Original Message -----

Sent: Monday, October 10, 2011 11:28 AM

Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

 

Jon answered why your syntax should have been more like
compute straight = VAR1 EQ VAR2 AND VAR2 EQ VAR3 AND VAR3 EQ VAR4 ...

However.
compute straight = sd(var1 to var6) eq 0. 

should also work.

Art Kendall
Social Research Consultants

On 10/10/2011 10:45 AM, David B. Nolle wrote:

Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

David B. Nolle-2
In reply to this post by Melissa Ives
Melissa,
 
Your compute statement seems to work in my test case because all 67 straights are identified correctly.
 
David
----- Original Message -----
Sent: Monday, October 10, 2011 2:35 PM
Subject: RE: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

Wouldn’t it also work to say

Compute straight=(max.6(v1 to v6)=min.6(v1 to v6).

 

?

Melissa

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David B. Nolle
Sent: Monday, October 10, 2011 10:59 AM
To: [hidden email]
Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

 

Jon,

 

Thank you for your prompt expert advice.

 

I now see why my first syntax identified no cases of straights involving, for example, all 2's or all 3's or all 4's (which are actually present in the test file). Moreover, I now see why the pattern of 2,2,1,1,1,1 (across the six variables) was successful: Because the first two values are true (which equals 1) and the remaining values are all 1's, SPSS evaluates all of the equivalencies as true.

 

David   

----- Original Message -----

Sent: Monday, October 10, 2011 10:55 AM

Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

 

Although your first syntax is valid, it does not mean what you think it does.
compute agrees = x=y=z
for example, is evaluated as
(x=y) = z.
If x = y, the result is true (1), so the second
part evaluates as
1 = z.
If x ne y, the x=y expression evaluates as false (0), so the second test is
0 = z.

HTH,

Jon Peck (no "h")
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621




From:        "David B. Nolle" <[hidden email]>
To:        [hidden email]
Date:        10/10/2011 08:46 AM
Subject:        [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS
Sent by:        "SPSSX(r) Discussion" <[hidden email]>





Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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



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: Processing Logic for Equivalencies or Straights in SPSS

David Marso
Administrator
In reply to this post by David B. Nolle-2
Raising the bar:
This is hardly a real world scenario!!!
More likely is a situation where there are a load of variables and one wishes to identify sequences of same answers;   In fact perhaps enumerate the number of such occurrences.  The following *UNTESTED* code should do this:
VECTOR Vars=Var001 to var100.
VECTOR ST6FND(17).
COMPUTE #FOUND=1.
COMPUTE #TARGET=vars(1).
COMPUTE #STR6=1.
COMPUTE #START=1.

LOOP ##=2 to 100.
+  DO IF Vars(##)=#TARGET.
+    COMPUTE #STR6=#STR6+1.
+    DO IF #STR6=6.
+      COMPUTE ST6FND(#FOUND)=#START.
+      COMPUTE #FOUND=#FOUND+1.
+      COMPUTE #STR6=0.
+      COMPUTE #START=##.
+    END IF.
+  ELSE.
+    COMPUTE #TARGET=Vars(##).
+    COMPUTE #START=##.
+  END IF.
END LOOP.
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?"
Reply | Threaded
Open this post in threaded view
|

Re: Processing Logic for Equivalencies or Straights in SPSS

John F Hall
In reply to this post by John F Hall

David

 

My mistake: should have checked it first.  I had two two periods in the do repeat command (end of 2nd and 3rd lines) but there only be one at the end of the dummy variable specs.

 

do repeat.

Y = 1 to 6.

 

This should work.

 

John

 

compute serial = $casenum.

do repeat

    Y = 1 to 6

  /Z = straight1 to straight6.

count z = var1 to var6 (y).

count straights = straight1 to strait6 (6).

end repeat.

temp.

select if straights eq 6.

list serial straight1 to straight6.

 

 

From: David B. Nolle [mailto:[hidden email]]
Sent: 11 October 2011 00:17
To: John F Hall
Cc: 'Bruce Weaver'
Subject: Re: Processing Logic for Equivalencies or Straights in SPSS

 

John,

 

Thank you for your response.  I have been unable to run your suggested syntax because I get a series of error messages (see below).

 

David

Error # 4521 in column 1024. Text: (End of Command)

The DO REPEAT command does not contain a variable to substitute.

Execution of this command stops.

Error # 1. Command name: Y

The first word in the line is not recognized as an SPSS Statistics command.

Execution of this command stops.

/Z = straight1 to straight6.

Error # 1. Command name: /Z

The first word in the line is not recognized as an SPSS Statistics command.

Execution of this command stops.

count z = var1 to var6 (y).

Error # 4772 in column 25. Text: y

On the COUNT command, the parenthesized value list is syntactically invalid.

Execution of this command stops.

count straights = straight1 to straight6 (6).

Error # 4285 in column 19. Text: straight1

Incorrect variable name: either the name is more than 64 characters, or it is

not defined by a previous command.

Execution of this command stops.

Error # 4285 in column 32. Text: straight6

Incorrect variable name: either the name is more than 64 characters, or it is

not defined by a previous command.

end repeat.

Error # 4001. Command name: end repeat

An END REPEAT command has appeared without a previous DO REPEAT command.

Execution of this command stops.

temporary.

select if (straights eq 6).

Error # 4285 in column 12. Text: straights

Incorrect variable name: either the name is more than 64 characters, or it is

not defined by a previous command.

Execution of this command stops.

list var=ID straight1 to straight6.

 

----- Original Message -----

Sent: Monday, October 10, 2011 2:51 PM

Subject: RE: Processing Logic for Equivalencies or Straights in SPSS

 

David

 

If you want to identify which value(s) the straights are in which case, try (untested):

 

compute serial = $casenum.

do repeat.

Y = 1 to 6.

/Z = straight1 to straight6.

count z = var1 to var6 (y).

count straights = straight1 to strait6 (6).

end repeat.

temp.

select if straights eq 6.

list serial straight1 to straight6.

 

 

John F Hall

 

[hidden email]

www.surveyresearch.weebly.com

 

 

 

 

 

From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of David B. Nolle
Sent: 10 October 2011 18:31
To: [hidden email]
Subject: Re: Processing Logic for Equivalencies or Straights in SPSS

 

Art,

 

Thank you for seconding Jon's explanation and for the alternative (parsimonious) syntax which does indeed identify the correct 67 cases. 

 

David 

----- Original Message -----

Sent: Monday, October 10, 2011 11:28 AM

Subject: Re: [SPSSX-L] Processing Logic for Equivalencies or Straights in SPSS

 

Jon answered why your syntax should have been more like
compute straight = VAR1 EQ VAR2 AND VAR2 EQ VAR3 AND VAR3 EQ VAR4 ...

However.
compute straight = sd(var1 to var6) eq 0. 

should also work.

Art Kendall
Social Research Consultants

On 10/10/2011 10:45 AM, David B. Nolle wrote:

Dear SPSS Experts,

I am wondering about the internal logic that SPSS uses to process
equivalencies or straights in SPSS 19.0.0.1. Specifically I want to evaluate
six numeric (single digit) variables to determine whether they are all equal
(equivalent) in value.  I have developed an SPSS test file with 5500 cases
having six numeric variables whose values vary from 1 to 9. I know that the
file has exactly 67 cases whose values are identical on all six variables
(for example, all 1, all 2, all 3, etc.).  When I use the following syntax
(call it straight), I discover that SPSS correctly identifies only 29 cases
and falsely identifies 5 additional cases as straights or equivalent on all
6 variables when they are clearly not equivalent or straights:

COMPUTE STRAIGHT=0.
IF VAR1=VAR2=VAR3=VAR4=VAR5=VAR6 STRAIGHT=1.

For example, when I use the foregoing syntax, I find that cases with the
pattern of values (2,2,1,1,1,1) are selected but I know that a correct case
is either 1,1,1,1,1,1 on all six variables or 2,2,2,2,2,2 on all six
variables.

Meanwhile, when I use the following syntax (call it straight6), I find all
67 cases correctly without any erroneous identifications:

COMPUTE STRAIGHT6=0.
IF (VAR1=VAR2) and (VAR2=VAR3) and (VAR3=VAR4) and (VAR4=VAR5) and
(VAR5=VAR6) STRAIGHT6=1.

I am wondering why the first syntax (straight) fails. Although I am guessing
that the two syntaxes are logically equivalent, I am obviously wrong. Thus,
I welcome your feedback.

Thank you for your time and in interest.

David B. Nolle

=====================
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: Processing Logic for Equivalencies or Straights in SPSS

David B. Nolle
In reply to this post by David B. Nolle-2
David,
 
I am sorry for my tardy response to your efforts regarding syntax for detecting straights.  I appreciate your efforts at "raising the bar" in your email to the SPSS list even though I never tried Dick Fosbury's Flop.  
 
Your SPSS syntax does indeed correctly identify the 67 cases with straights in my test datafile involving only six variables. However, further testing will be needed to see whether your syntax applies to a file having more variables.
 
David
 
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Processing Logic for Equivalencies or Straights in SPSS

David Marso
Administrator
Slight modification:
Forgot to reinitialize #STR6 when encountering new value (ELSE clause).
Also should be reset to 1 within the inner conditional:
REVISED code:
*TEST DATA GENERATOR*.
INPUT PROGRAM.
LOOP CASE=1 to 1000.
DO REPEAT V=Var001 to var100.
COMPUTE V=UNIFORM(1)< .7 .
END REPEAT.
END CASE.
END LOOP.
END FILE.
END INPUT PROGRAM.

VECTOR Vars=Var001 to var100.
VECTOR ST6FND(17).
COMPUTE #FOUND=1.
COMPUTE #TARGET=vars(1).
COMPUTE #STR6=1.
COMPUTE #START=1.

LOOP ##=2 to 100.
+  DO IF Vars(##)=#TARGET.
+    COMPUTE #STR6=#STR6+1.
+    DO IF #STR6=6.
+      COMPUTE ST6FND(#FOUND)=#START.
+      COMPUTE #FOUND=#FOUND+1.
+      COMPUTE #STR6=1.
+      COMPUTE #START=##.
+    END IF.
+  ELSE.
+    COMPUTE #TARGET=Vars(##).
+    COMPUTE #START=##.
+    COMPUTE #STR6=1.
+  END IF.
END LOOP.
FORMATS ALL (F3.0).

On Fri, Oct 14, 2011 at 2:44 PM, David B. Nolle <[hidden email]> wrote:

> David,
>
> I am sorry for my tardy response to your efforts regarding syntax for
> detecting straights.  I appreciate your efforts at "raising the bar" in your
> email to the SPSS list even though I never tried Dick Fosbury's Flop.
>
> Your SPSS syntax does indeed correctly identify the 67 cases with straights
> in my test datafile involving only six variables. However, further testing
> will be needed to see whether your syntax applies to a file having more
> variables.
>
> David
>
>
>

=====================
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
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?"