Problems with logical expression

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

Problems with logical expression

mikelowski
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Problems with logical expression

Bruce Weaver
Administrator
You need to include a "not missing" check.  Something like this:

compute out = 0.
do repeat v = v1 to v5 / x = 2 4 6 8 10.
-  compute out = out + (not missing(v) and v EQ x).
end repeat.
temporary.
SELECT IF out EQ 0.
execute.


mikelowski wrote
I have a silly problem. Imagine you have five variables, and you want to delete the cases with X values of every variable.

V1: cases with value 2... out
V2: cases with value 4... out
V3: cases with value 6... out
V4: cases with values 8... out
V5: cases with  values 10... out

The syntax:

SELECT IF NOT (V1=2 or V2=4 or V3=6 or V4=8 or V5=10).
EXECUTE.

The problem is that there are SYSMIS values in V3, and I don't want to delete they, but with this syntax they are deleted :S

(Note that I use OR condition, so, I want all cases that meet one or more of these criteria, not just the cases that meet all the criteria).

Thanks people ;)
--
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: Problems with logical expression

David Marso
Administrator
SELECT IF NOT(ANY(1,V1 EQ 2,V2 EQ 4,V3 EQ 6,V4 EQ 8,V5 EQ 10)).
or
SELECT IF SUM(V1 EQ 2,V2 EQ 4,V3 EQ 6,V4 EQ 8 ,V5 EQ 10) EQ 0.
or
...
SELECT IF SUM(V1=2,V2=4,V3=6,V4=8 ,V5=10) =0. /* But trying to break the habit of = vs EQ */.

Bruce Weaver wrote
You need to include a "not missing" check.  Something like this:

compute out = 0.
do repeat v = v1 to v5 / x = 2 4 6 8 10.
-  compute out = out + (not missing(v) and v EQ x).
end repeat.
temporary.
SELECT IF out EQ 0.
execute.


mikelowski wrote
I have a silly problem. Imagine you have five variables, and you want to delete the cases with X values of every variable.

V1: cases with value 2... out
V2: cases with value 4... out
V3: cases with value 6... out
V4: cases with values 8... out
V5: cases with  values 10... out

The syntax:

SELECT IF NOT (V1=2 or V2=4 or V3=6 or V4=8 or V5=10).
EXECUTE.

The problem is that there are SYSMIS values in V3, and I don't want to delete they, but with this syntax they are deleted :S

(Note that I use OR condition, so, I want all cases that meet one or more of these criteria, not just the cases that meet all the criteria).

Thanks people ;)
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: Problems with logical expression

John F Hall
In reply to this post by mikelowski
Try something like:

do repeat
 xv = xv1 to xv5
 /y = v1 to v5
 /z = 2, 4, 6, 8, 10.
count xv = y (z).
end repeat.

freq xv1 to xv5.

Then, if I follow your logic correctly, carry on with:

count reject = xv1 to xv5 (1).
freq reject.

select if (reject = 0).


John F Hall

[hidden email]
www.surveyresearch.weebly.com





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
mikelowski
Sent: 14 October 2011 09:07
To: [hidden email]
Subject: Problems with logical expression

I have a silly problem. Imagine you have five variables, and you want to
delete the cases with X values of every variable.

V1: cases with value 2... out
V2: cases with value 4... out
V3: cases with value 6... out
V4: cases with values 8... out
V5: cases with  values 10... out

I don't know how to express this in logical expression. I tried with filter
and I only achieve to select cases V1=2. Obviously, I do something wrong.
For simplicity, here better use the command 'SELECT IF NOT' to show how to
do this.

SELECT IF NOT ((V1=2) or (V2=4) or (V3=6) or (V4=8 or (V5=10)).
EXECUTE.

(Note that I use OR condition, so, I want all cases that meet one or more of
these criteria, not a cases that meet all the criteria).

By the way, there aren't some guide for large logical expressions that
contains multiple variables? The SPSS syntax reference it's too much
concise.

Thanks people ;)

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Problems-with-logical-expressi
on-tp4901624p4901624.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
Reply | Threaded
Open this post in threaded view
|

Re: Problems with logical expression

David Marso
Administrator
John,
Why bother with the DO REPEAT ?
Note that count permits multiple varlist/value pairings!!!
COUNT DELETE=v1 (2) V2 (4) v3 (6) v4 (8) v5 (10).
--
COMPUTE FILTER=DELETE GT 0.
FILTER BY FILTER.
HTH, David


John F Hall wrote
Try something like:

do repeat
 xv = xv1 to xv5
 /y = v1 to v5
 /z = 2, 4, 6, 8, 10.
count xv = y (z).
end repeat.

freq xv1 to xv5.

Then, if I follow your logic correctly, carry on with:

count reject = xv1 to xv5 (1).
freq reject.

select if (reject = 0).


John F Hall

[hidden email]
www.surveyresearch.weebly.com





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
mikelowski
Sent: 14 October 2011 09:07
To: [hidden email]
Subject: Problems with logical expression

I have a silly problem. Imagine you have five variables, and you want to
delete the cases with X values of every variable.

V1: cases with value 2... out
V2: cases with value 4... out
V3: cases with value 6... out
V4: cases with values 8... out
V5: cases with  values 10... out

I don't know how to express this in logical expression. I tried with filter
and I only achieve to select cases V1=2. Obviously, I do something wrong.
For simplicity, here better use the command 'SELECT IF NOT' to show how to
do this.

SELECT IF NOT ((V1=2) or (V2=4) or (V3=6) or (V4=8 or (V5=10)).
EXECUTE.

(Note that I use OR condition, so, I want all cases that meet one or more of
these criteria, not a cases that meet all the criteria).

By the way, there aren't some guide for large logical expressions that
contains multiple variables? The SPSS syntax reference it's too much
concise.

Thanks people ;)

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Problems-with-logical-expressi
on-tp4901624p4901624.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
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: Problems with logical expression

John F Hall
David

In my experience the client always comes back wanting more detail or more
complex analysis.  This is anticipated by

freq xv1 to xv5 .

It's what I would do anyway as a routine data check.

John

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
David Marso
Sent: 16 October 2011 16:46
To: [hidden email]
Subject: Re: Problems with logical expression

John,
Why bother with the DO REPEAT ?
Note that count permits multiple varlist/value pairings!!!
COUNT DELETE=v1 (2) V2 (4) v3 (6) v4 (8) v5 (10).
--
COMPUTE FILTER=DELETE GT 0.
FILTER BY FILTER.
HTH, David



John F Hall wrote:

>
> Try something like:
>
> do repeat
>  xv = xv1 to xv5
>  /y = v1 to v5
>  /z = 2, 4, 6, 8, 10.
> count xv = y (z).
> end repeat.
>
> freq xv1 to xv5.
>
> Then, if I follow your logic correctly, carry on with:
>
> count reject = xv1 to xv5 (1).
> freq reject.
>
> select if (reject = 0).
>
>
> John F Hall
>
> johnfhall@
> www.surveyresearch.weebly.com
>
>
>
>
>
> -----Original Message-----
> From: SPSSX(r) Discussion [mailto:SPSSX-L@.UGA] On Behalf Of
> mikelowski
> Sent: 14 October 2011 09:07
> To: SPSSX-L@.UGA
> Subject: Problems with logical expression
>
> I have a silly problem. Imagine you have five variables, and you want to
> delete the cases with X values of every variable.
>
> V1: cases with value 2... out
> V2: cases with value 4... out
> V3: cases with value 6... out
> V4: cases with values 8... out
> V5: cases with  values 10... out
>
> I don't know how to express this in logical expression. I tried with
> filter
> and I only achieve to select cases V1=2. Obviously, I do something wrong.
> For simplicity, here better use the command 'SELECT IF NOT' to show how to
> do this.
>
> SELECT IF NOT ((V1=2) or (V2=4) or (V3=6) or (V4=8 or (V5=10)).
> EXECUTE.
>
> (Note that I use OR condition, so, I want all cases that meet one or more
> of
> these criteria, not a cases that meet all the criteria).
>
> By the way, there aren't some guide for large logical expressions that
> contains multiple variables? The SPSS syntax reference it's too much
> concise.
>
> Thanks people ;)
>
> --
> View this message in context:
>
http://spssx-discussion.1045642.n5.nabble.com/Problems-with-logical-expressi

> on-tp4901624p4901624.html
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA (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
> LISTSERV@.UGA (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
>


--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Problems-with-logical-expressi
on-tp4901624p4907050.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
Reply | Threaded
Open this post in threaded view
|

Re: Problems with logical expression

Rich Ulrich
In reply to this post by David Marso
Great!  I didn't know that!  Has it always been that way?

How do you want to count up the correct answers to a
questionnaire?  - Just list all the variables in sets, followed
by what the correct answer is for the sets of '1', '2', etc.

--
Rich Ulrich

> Date: Sun, 16 Oct 2011 07:45:45 -0700
> From: [hidden email]
> Subject: Re: Problems with logical expression
> To: [hidden email]
>
> John,
> Why bother with the DO REPEAT ?
> Note that count permits multiple varlist/value pairings!!!
> COUNT DELETE=v1 (2) V2 (4) v3 (6) v4 (8) v5 (10).
> --
[snip, rest]
Reply | Threaded
Open this post in threaded view
|

Re: Problems with logical expression

David Marso
Administrator
AFAIK  It has been that way since the devil was a little boy.
I don't recall anything prior to SPSS-X ver 2 (Blue manual), but could swear this same syntax existed in 1990.  Anyone have an ancient manual around to double check this?
Rich Ulrich-2 wrote
Great!  I didn't know that!  Has it always been that way?

How do you want to count up the correct answers to a
questionnaire?  - Just list all the variables in sets, followed
by what the correct answer is for the sets of '1', '2', etc.

--
Rich Ulrich

> Date: Sun, 16 Oct 2011 07:45:45 -0700
> From: [hidden email]
> Subject: Re: Problems with logical expression
> To: [hidden email]
>
> John,
> Why bother with the DO REPEAT ?
> Note that count permits multiple varlist/value pairings!!!
> COUNT DELETE=v1 (2) V2 (4) v3 (6) v4 (8) v5 (10).
> --
[snip, rest]
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: Problems with logical expression

Art Kendall
I did not find the COUNT with multiple lists in the 1970 manual.
I did find it in the 1983 manual.

I have a vague memory of it being there fairly early maybe 1976?

Art Kendall

On 10/16/2011 5:03 PM, David Marso wrote:
AFAIK  It has been that way since the devil was a little boy.
I don't recall anything prior to SPSS-X ver 2 (Blue manual), but could swear
this same syntax existed in 1990.  Anyone have an ancient manual around to
double check this?

Rich Ulrich-2 wrote:
Great!  I didn't know that!  Has it always been that way?

How do you want to count up the correct answers to a
questionnaire?  - Just list all the variables in sets, followed
by what the correct answer is for the sets of '1', '2', etc.

--
Rich Ulrich

Date: Sun, 16 Oct 2011 07:45:45 -0700
From: david.marso@
Subject: Re: Problems with logical expression
To: [hidden email]

John,
Why bother with the DO REPEAT ?
Note that count permits multiple varlist/value pairings!!!
COUNT DELETE=v1 (2) V2 (4) v3 (6) v4 (8) v5 (10).
--
[snip, rest]


--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Problems-with-logical-expression-tp4901624p4907753.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