cleaning data in SPSS 19: applying several rules to single variable validation

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

cleaning data in SPSS 19: applying several rules to single variable validation

martien
I'm trying to make sure all values in my dataset are within the specified range. I can define several rules, but when i do the validation check, the program does not apply them the way that i want them to and i do not know what i'm doing wrong.

For example:

The answer to a question about cost should be validated if the answer is either -97 (which specifies "don't know" in my dataset) or between 0 to 1 million. I defined 2 single variable rules:
1: range: between 0 to 1 million
2: list: -97

Now, if i validate my data and tick these two rules for one variable, the system only validates cases that comply with rule 1 AND rule 2. This is a problem. I want the system to validate cases which comply with rule 1 OR rule 2. How can i do this?
Reply | Threaded
Open this post in threaded view
|

Re: cleaning data in SPSS 19: applying several rules to single variable validation

Bruce Weaver
Administrator
It would help if you provided your syntax.  Assuming that -97 is not currently a missing value, the following should work.

COMPUTE CostOK = (cost EQ -97) OR RANGE(cost,0,1000000).

Or...

COMPUTE CostOK = RANGE(cost,-97,-97,0,1000000).

If -97 is a missing value, you could either temporarily make it a valid value, or you could insert the VALUE() function where necessary.  Something like this (untested):

COMPUTE CostOK = (VALUE(cost) EQ -97) OR RANGE(cost,0,1000000).

Or...

COMPUTE CostOK = RANGE(VALUE(cost),-97,-97,0,1000000).

HTH.


martien wrote
I'm trying to make sure all values in my dataset are within the specified range. I can define several rules, but when i do the validation check, the program does not apply them the way that i want them to and i do not know what i'm doing wrong.

For example:

The answer to a question about cost should be validated if the answer is either -97 (which specifies "don't know" in my dataset) or between 0 to 1 million. I defined 2 single variable rules:
1: range: between 0 to 1 million
2: list: -97

Now, if i validate my data and tick these two rules for one variable, the system only validates cases that comply with rule 1 AND rule 2. This is a problem. I want the system to validate cases which comply with rule 1 OR rule 2. How can i do this?
--
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
|

Automatic reply: cleaning data in SPSS 19: applying several rules to single variable validation

Choncek, Chris

I will be out of the office on Monday, Nov. 5th and Tuesday, Nov. 6th. I will return to the office on Wednesday, November 7th. Should you need immediate assistance, you may contact Marcia Druga at [hidden email].

 

Reply | Threaded
Open this post in threaded view
|

Re: cleaning data in SPSS 19: applying several rules to single variable validation

Jon K Peck
In reply to this post by martien
The logic of the data validation rules is that they all have to be satisfied in order for a value to be valid, so rules are joined with AND.
In your particular example, since you have presumably defined -97 as a user-missing value, you can just use a range rule and uncheck the box "Allow user-missing values".

More generally, if have a condition that can't be expressed using the simple single-variable rules structure, write a cross-variable rules that spells out the validation condition as a cross-variable rule.  Note that the True value (1) means that the rule is violated.


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




From:        martien <[hidden email]>
To:        [hidden email],
Date:        11/05/2012 02:06 AM
Subject:        [SPSSX-L] cleaning data in SPSS 19: applying several rules to              single              variable validation
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




I'm trying to make sure all values in my dataset are within the specified
range. I can define several rules, but when i do the validation check, the
program does not apply them the way that i want them to and i do not know
what i'm doing wrong.

For example:

The answer to a question about cost should be validated if the answer is
either -97 (which specifies "don't know" in my dataset) or between 0 to 1
million. I defined 2 single variable rules:
1: range: between 0 to 1 million
2: list: -97

Now, if i validate my data and tick these two rules for one variable, the
system only validates cases that comply with rule 1 AND rule 2. This is a
problem. I want the system to validate cases which comply with rule 1 OR
rule 2. How can i do this?



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/cleaning-data-in-SPSS-19-applying-several-rules-to-single-variable-validation-tp5716032.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


Reply | Threaded
Open this post in threaded view
|

Re: cleaning data in SPSS 19: applying several rules to single variable validation

John F Hall
In reply to this post by Bruce Weaver
You could also try (in syntax):

count x = cost (-97, 0 thru 1000000).

Cases falling outside the value range will have x = 0.  If you want to know
which cases they are:

temp.
select if (x = 0).
list serial.

[or ID or whatever your individual caseno is]

If you haven't got an individual ID you need to do:

compute ID = $casenum.
temp.
select if (x = 0).
list casenum.


John F Hall (Mr)

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





-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Bruce Weaver
Sent: 05 November 2012 14:50
To: [hidden email]
Subject: Re: cleaning data in SPSS 19: applying several rules to single
variable validation

It would help if you provided your syntax.  Assuming that -97 is not
currently a missing value, the following should work.

COMPUTE CostOK = (cost EQ -97) OR RANGE(cost,0,1000000).

Or...

COMPUTE CostOK = RANGE(cost,-97,-97,0,1000000).

If -97 is a missing value, you could either temporarily make it a valid
value, or you could insert the VALUE() function where necessary.  Something
like this (untested):

COMPUTE CostOK = (VALUE(cost) EQ -97) OR RANGE(cost,0,1000000).

Or...

COMPUTE CostOK = RANGE(VALUE(cost),-97,-97,0,1000000).

HTH.



martien wrote

> I'm trying to make sure all values in my dataset are within the
> specified range. I can define several rules, but when i do the
> validation check, the program does not apply them the way that i want
> them to and i do not know what i'm doing wrong.
>
> For example:
>
> The answer to a question about cost should be validated if the answer
> is either -97 (which specifies "don't know" in my dataset) or between
> 0 to 1 million. I defined 2 single variable rules:
> 1: range: between 0 to 1 million
> 2: list: -97
>
> Now, if i validate my data and tick these two rules for one variable,
> the system only validates cases that comply with rule 1 AND rule 2.
> This is a problem. I want the system to validate cases which comply
> with rule 1 OR rule 2. How can i do this?





-----
--
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/cleaning-data-in-SPSS-19-apply
ing-several-rules-to-single-variable-validation-tp5716032p5716033.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: cleaning data in SPSS 19: applying several rules to single variable validation

martien
In reply to this post by martien
Thanks. I don't know how to work with syntax, but i can include all criteria in cross variable rules.
Reply | Threaded
Open this post in threaded view
|

Re: cleaning data in SPSS 19: applying several rules to single variable validation

John F Hall
It's always worth learning some syntax: much quicker and easier for some
tasks.  Have a look at the SPSS tutorials on my website.

In your Data Editor, click on:

File > New > syntax

Then write/copy/paste the syntax into it (don't forget the full stops).

Click on Run > All or highlight text and press green triangle, et voila!

John F Hall (Mr)

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






-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
martien
Sent: 06 November 2012 02:04
To: [hidden email]
Subject: Re: cleaning data in SPSS 19: applying several rules to single
variable validation

Thanks. I don't know how to work with syntax, but i can include all criteria
in cross variable rules.



--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/cleaning-data-in-SPSS-19-apply
ing-several-rules-to-single-variable-validation-tp5716032p5716042.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