SPSS 15 syntax IF command bug?

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

SPSS 15 syntax IF command bug?

eblange
Hi all,

I am very concerned about the following problem: I am running a simple (if a and b then c) syntax command in SPSS 15 and it does not work properly. Basically the outcome is nonsense. The problem is replicable. I was even playing around with different ways of putting brackets. Still nonsense. I renamed the variable (getting ride of the "to"-part), still nonsense. The same routine runs on SPSS 14 (on a different PC) nicely. An example of the exact code is in the end of this message.
I am very worried and would be very happy if someone has an idea why SPSS 15 is behaving crazy, and what I can do about this. The PC with SPSS 15 is an old pentium 4, with 512 RAM and just 4 GB left on the harddrive. This is not much, but should be sufficient.

Thanks for your help,
Elke


if (tarpos=1 and ovlappos=1) to_pos1=cvc11.
if (tarpos=1 and ovlappos=2) to_pos1=cvc12.
if (tarpos=1 and ovlappos=3) to_pos1=cvc13.

if (tarpos=2 and ovlappos=1) to_pos2=cvc21.
if (tarpos=2 and ovlappos=2) to_pos2=cvc22.
if (tarpos=2 and ovlappos=3) to_pos2=cvc23.

if (tarpos=3 and ovlappos=1) to_pos3=cvc31.
if (tarpos=3 and ovlappos=2) to_pos3=cvc32.
if (tarpos=3 and ovlappos=3) to_pos3=cvc33.
exe.
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

Beadle, ViAnn
you haven't explained exactly why your outcome is nonsense. The usual suspect is missing values.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of eblange
Sent: Thursday, May 03, 2007 1:40 AM
To: [hidden email]
Subject: SPSS 15 syntax IF command bug?

Hi all,

I am very concerned about the following problem: I am running a simple (if a
and b then c) syntax command in SPSS 15 and it does not work properly.
Basically the outcome is nonsense. The problem is replicable. I was even
playing around with different ways of putting brackets. Still nonsense. I
renamed the variable (getting ride of the "to"-part), still nonsense. The
same routine runs on SPSS 14 (on a different PC) nicely. An example of the
exact code is in the end of this message.
I am very worried and would be very happy if someone has an idea why SPSS 15
is behaving crazy, and what I can do about this. The PC with SPSS 15 is an
old pentium 4, with 512 RAM and just 4 GB left on the harddrive. This is not
much, but should be sufficient.

Thanks for your help,
Elke


if (tarpos=1 and ovlappos=1) to_pos1=cvc11.
if (tarpos=1 and ovlappos=2) to_pos1=cvc12.
if (tarpos=1 and ovlappos=3) to_pos1=cvc13.

if (tarpos=2 and ovlappos=1) to_pos2=cvc21.
if (tarpos=2 and ovlappos=2) to_pos2=cvc22.
if (tarpos=2 and ovlappos=3) to_pos2=cvc23.

if (tarpos=3 and ovlappos=1) to_pos3=cvc31.
if (tarpos=3 and ovlappos=2) to_pos3=cvc32.
if (tarpos=3 and ovlappos=3) to_pos3=cvc33.
exe.

--
View this message in context: http://www.nabble.com/SPSS-15-syntax-IF-command-bug--tf3685036.html#a10300329
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

Oliver, Richard
In reply to this post by eblange
First of all, what are you actually trying to do? If you're trying to create three string variables with values such as "cvc11", your code won't do it. The string variables must be declared first, and the string values in the IF statements must be quoted, as in:

string to_pos1 to_pos2 to_pos3 (a5).
if (tarpos=1 and ovlappos=1) to_pos1="cvc11".
Etc.

Without the quotes, then the code basically says "make the value of variable to_pos1 equal to the value of variable cvc11" -- and if there is no variable cvc11, you'll get an error.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of eblange
Sent: Thursday, May 03, 2007 2:40 AM
To: [hidden email]
Subject: SPSS 15 syntax IF command bug?

Hi all,

I am very concerned about the following problem: I am running a simple (if a
and b then c) syntax command in SPSS 15 and it does not work properly.
Basically the outcome is nonsense. The problem is replicable. I was even
playing around with different ways of putting brackets. Still nonsense. I
renamed the variable (getting ride of the "to"-part), still nonsense. The
same routine runs on SPSS 14 (on a different PC) nicely. An example of the
exact code is in the end of this message.
I am very worried and would be very happy if someone has an idea why SPSS 15
is behaving crazy, and what I can do about this. The PC with SPSS 15 is an
old pentium 4, with 512 RAM and just 4 GB left on the harddrive. This is not
much, but should be sufficient.

Thanks for your help,
Elke


if (tarpos=1 and ovlappos=1) to_pos1=cvc11.
if (tarpos=1 and ovlappos=2) to_pos1=cvc12.
if (tarpos=1 and ovlappos=3) to_pos1=cvc13.

if (tarpos=2 and ovlappos=1) to_pos2=cvc21.
if (tarpos=2 and ovlappos=2) to_pos2=cvc22.
if (tarpos=2 and ovlappos=3) to_pos2=cvc23.

if (tarpos=3 and ovlappos=1) to_pos3=cvc31.
if (tarpos=3 and ovlappos=2) to_pos3=cvc32.
if (tarpos=3 and ovlappos=3) to_pos3=cvc33.
exe.

--
View this message in context: http://www.nabble.com/SPSS-15-syntax-IF-command-bug--tf3685036.html#a10300329
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

Richard Ristow
In reply to this post by eblange
At 03:40 AM 5/3/2007, eblange wrote:

>I am very concerned about the following problem: I am running a simple
>(if a and b then c) syntax command in SPSS 15 and it does not work
>properly. Basically the outcome is nonsense.

Ouch. And simply inspecting the code, I don't see anything.

In any problem with manipulating data, it helps if we can have

- A sample of the input data, preferably enough to use as test data

- Not just that the output was wrong, but what was the output you
wanted, and what you got instead

- If there were any error or warning messages, the listing with the
messages and the code that elicited them.

These should all be exact; a description or paraphrase will rarely do
it. For level of detail, debugging is about like proofreading text.

Good luck, and it would be fascinating to have a look at it,
Richard Ristow
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

eblange
In reply to this post by Beadle, ViAnn
Hi,
thanks for the reply. I am trying to shovel a spreadsheet that consists of numeric variables. The input are the variables CVC11 to CVC33, coded as 1 and 0. The critical variables tarpos and ovlappos can have the value 1 to 3. The  three output variables are supposed to create 2 missing values and one rewritten value from CVC11 to CVC33. What happen is:
a) more then one output variable gets a value.
b) sometimes the output values have no relation to the input values (e.g. are .5 instead of 1 or 0).

Anyway. I tried this syntax on different PCs and everywhere the same problem. So the installation CD might have a bug. As other users reported no problem.
Have a good day,
Elke

Beadle, ViAnn wrote
you haven't explained exactly why your outcome is nonsense. The usual suspect is missing values.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of eblange
Sent: Thursday, May 03, 2007 1:40 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: SPSS 15 syntax IF command bug?

Hi all,

I am very concerned about the following problem: I am running a simple (if a
and b then c) syntax command in SPSS 15 and it does not work properly.
Basically the outcome is nonsense. The problem is replicable. I was even
playing around with different ways of putting brackets. Still nonsense. I
renamed the variable (getting ride of the "to"-part), still nonsense. The
same routine runs on SPSS 14 (on a different PC) nicely. An example of the
exact code is in the end of this message.
I am very worried and would be very happy if someone has an idea why SPSS 15
is behaving crazy, and what I can do about this. The PC with SPSS 15 is an
old pentium 4, with 512 RAM and just 4 GB left on the harddrive. This is not
much, but should be sufficient.

Thanks for your help,
Elke


if (tarpos=1 and ovlappos=1) to_pos1=cvc11.
if (tarpos=1 and ovlappos=2) to_pos1=cvc12.
if (tarpos=1 and ovlappos=3) to_pos1=cvc13.

if (tarpos=2 and ovlappos=1) to_pos2=cvc21.
if (tarpos=2 and ovlappos=2) to_pos2=cvc22.
if (tarpos=2 and ovlappos=3) to_pos2=cvc23.

if (tarpos=3 and ovlappos=1) to_pos3=cvc31.
if (tarpos=3 and ovlappos=2) to_pos3=cvc32.
if (tarpos=3 and ovlappos=3) to_pos3=cvc33.
exe.

--
View this message in context: http://www.nabble.com/SPSS-15-syntax-IF-command-bug--tf3685036.html#a10300329
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

eblange
In reply to this post by Oliver, Richard
Dear Richard,

thank you very much for the reply. Very good reasoning, but the CVC variables are numeric variables with the values 1 or 0. I am trying to rearrange data in a way that the three output variables (to_pos1 .. to_pos3) get either missing values (two of them) or one of the values of the six input variables (CVC11..CVC33).  

And I have to say I gonna give up, as the bug shows up on a couple of other PCs as well. So there might be a bug in the installation CD. Even rewritting the syntax with "DO IF..ELSE IF" creates the same problematic output.

Cheers,
Elke

Oliver, Richard wrote
First of all, what are you actually trying to do? If you're trying to create three string variables with values such as "cvc11", your code won't do it. The string variables must be declared first, and the string values in the IF statements must be quoted, as in:

string to_pos1 to_pos2 to_pos3 (a5).
if (tarpos=1 and ovlappos=1) to_pos1="cvc11".
Etc.

Without the quotes, then the code basically says "make the value of variable to_pos1 equal to the value of variable cvc11" -- and if there is no variable cvc11, you'll get an error.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:SPSSX-L@LISTSERV.UGA.EDU] On Behalf Of eblange
Sent: Thursday, May 03, 2007 2:40 AM
To: SPSSX-L@LISTSERV.UGA.EDU
Subject: SPSS 15 syntax IF command bug?

Hi all,

I am very concerned about the following problem: I am running a simple (if a
and b then c) syntax command in SPSS 15 and it does not work properly.
Basically the outcome is nonsense. The problem is replicable. I was even
playing around with different ways of putting brackets. Still nonsense. I
renamed the variable (getting ride of the "to"-part), still nonsense. The
same routine runs on SPSS 14 (on a different PC) nicely. An example of the
exact code is in the end of this message.
I am very worried and would be very happy if someone has an idea why SPSS 15
is behaving crazy, and what I can do about this. The PC with SPSS 15 is an
old pentium 4, with 512 RAM and just 4 GB left on the harddrive. This is not
much, but should be sufficient.

Thanks for your help,
Elke


if (tarpos=1 and ovlappos=1) to_pos1=cvc11.
if (tarpos=1 and ovlappos=2) to_pos1=cvc12.
if (tarpos=1 and ovlappos=3) to_pos1=cvc13.

if (tarpos=2 and ovlappos=1) to_pos2=cvc21.
if (tarpos=2 and ovlappos=2) to_pos2=cvc22.
if (tarpos=2 and ovlappos=3) to_pos2=cvc23.

if (tarpos=3 and ovlappos=1) to_pos3=cvc31.
if (tarpos=3 and ovlappos=2) to_pos3=cvc32.
if (tarpos=3 and ovlappos=3) to_pos3=cvc33.
exe.

--
View this message in context: http://www.nabble.com/SPSS-15-syntax-IF-command-bug--tf3685036.html#a10300329
Sent from the SPSSX Discussion mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

eblange
In reply to this post by Richard Ristow
Dear Richard,

thanks you for your reply. I decided that the problem has maybe to do with a bug on the installation CD. It is replicable on other PCs with the same version, and also with different ways to write IF commands (e.g., DO IF... ELSE IF). But nevertheless, if you would like to take a look at it would be nice.
 
input data (excerpt):

vpnr trial cvc11 cvc12 cvc13 cvc21 cvc22 cvc23 cvc31 cvc32 cvc33 tarpos ovlappos
1 1 1 1 1 0 0 0 0 1 1 2 1
1 2 1 1 1 1 1 1 1 1 1 1 2
1 3 0 0 0 0 0 0 0 1 1 1 1
1 4 1 1 1 1 1 1 1 1 0 1 3
1 5 1 1 1 1 0 1 1 1 1 3 3
1 6 0 0 0 0 0 1 0 0 0 3 1
1 7 1 1 1 1 1 1 1 1 1 2 3
1 8 1 1 1 0 1 0 0 0 0 2 2
1 9 0 0 0 0 0 0 0 0 0 3 2
1 10 0 0 0 1 1 1 1 1 1 3 2
1 11 0 0 0 1 1 0 1 1 0 2 3
1 12 1 1 1 1 1 1 1 1 1 1 1
1 13 1 1 1 1 1 1 1 1 1 3 3
1 14 1 1 0 1 1 1 0 1 0 2 1
1 15 0 1 1 0 0 0 1 1 1 1 2
1 16 1 1 1 1 1 1 1 1 1 3 1
1 17 0 0 0 1 1 0 0 1 0 2 2
1 18 1 1 1 1 1 1 1 1 1 1 3
1 19 0 1 1 0 1 1 1 1 1 2 1
1 20 1 1 1 1 1 1 1 1 1 3 1


output: The syntax should create 3 more variables (to_pos1 ..t_pos3) that show either a missing value (for two of them) or a rewritten value from the input CVC11 to CVC33. What I get is
a) sometimes all three variables get an input value, sometimes all three the same, sometimes different.
b) sometimes the value has no obvious relation to the input (e.g. 0.5 istead of 1 or 0)
c) sometimes everything looks alright, that is in maybe 1 out of 10 cases.

warning messages? Not at all!

Cheers,
Elke

Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

Art Kendall-2
In version 15 I used this syntax and got the tables below the syntax.
They show 6, 7, and 7 valid values for To_pos1 to to_pos3 corresponding
to the number of cases with 1,2 an3 for tarpos.

If this still shows the problem you are describing please add 6 more
variables to the example data.

getting1 to getting3 to show what you are getting on your system.
want1 to want3  to show what you want in to_pos1 to to_pos3.

You can get what I am asking for by manually adding want1 to want3,
doing a LIST, cut-and-paste to an email
and then editing the names of to_pos variables

data list list/vpnr (f1)    trial(f2)
   cvc11   cvc12   cvc13
   cvc21   cvc22   cvc23
   cvc31   cvc32   cvc33
   tarpos ovlappos (11f1).
begin data
1   1   1   1   1   0   0   0   0   1   1   2   1
1   2   1   1   1   1   1   1   1   1   1   1   2
1   3   0   0   0   0   0   0   0   1   1   1   1
1   4   1   1   1   1   1   1   1   1   0   1   3
1   5   1   1   1   1   0   1   1   1   1   3   3
1   6   0   0   0   0   0   1   0   0   0   3   1
1   7   1   1   1   1   1   1   1   1   1   2   3
1   8   1   1   1   0   1   0   0   0   0   2   2
1   9   0   0   0   0   0   0   0   0   0   3   2
1   10  0   0   0   1   1   1   1   1   1   3   2
1   11  0   0   0   1   1   0   1   1   0   2   3
1   12  1   1   1   1   1   1   1   1   1   1   1
1   13  1   1   1   1   1   1   1   1   1   3   3
1   14  1   1   0   1   1   1   0   1   0   2   1
1   15  0   1   1   0   0   0   1   1   1   1   2
1   16  1   1   1   1   1   1   1   1   1   3   1
1   17  0   0   0   1   1   0   0   1   0   2   2
1   18  1   1   1   1   1   1   1   1   1   1   3
1   19  0   1   1   0   1   1   1   1   1   2   1
1   20  1   1   1   1   1   1   1   1   1   3   1
end data.
*intialize result variables so we can see what falls through the "sieve".
* and to avoid the use of system missing.
numeric to_pos1 to to_pos3 (f1).
compute to_pos1 = -1.
compute to_pos2 = -1.
compute to_pos3 = -1.
* begin original transformations.
if (tarpos eq 1 and ovlappos eq 1) to_pos1=cvc11.
if (tarpos eq 1 and ovlappos eq 2) to_pos1=cvc12.
if (tarpos eq 1 and ovlappos eq 3) to_pos1=cvc13.

if (tarpos eq 2 and ovlappos eq 1) to_pos2=cvc21.
if (tarpos eq 2 and ovlappos eq 2) to_pos2=cvc22.
if (tarpos eq 2 and ovlappos eq 3) to_pos2=cvc23.

if (tarpos eq 3 and ovlappos eq 1) to_pos3=cvc31.
if (tarpos eq 3 and ovlappos eq 2) to_pos3=cvc32.
if (tarpos eq 3 and ovlappos eq 3) to_pos3=cvc33.
* end original transformations.
frequencies vars = to_pos1 to to_pos3.
crosstabs
  /variables = tarpos ovlappos (1,3) to_pos1 to to_pos3 (-1,1)
  /tables= tarpos by ovlappos
  /to_pos1 to to_pos3 by tarpos by ovlappos
  /missing=report.
* to_pos1*

        Frequency       Percent         Valid Percent   Cumulative Percent
Valid   -1      14      70.0    70.0    70.0
0       1       5.0     5.0     75.0
1       5       25.0    25.0    100.0
Total   20      100.0   100.0


* to_pos2*

        Frequency       Percent         Valid Percent   Cumulative Percent
Valid   -1      13      65.0    65.0    65.0
0       3       15.0    15.0    80.0
1       4       20.0    20.0    100.0
Total   20      100.0   100.0


* to_pos3*

        Frequency       Percent         Valid Percent   Cumulative Percent
Valid   -1      13      65.0    65.0    65.0
0       2       10.0    10.0    75.0
1       5       25.0    25.0    100.0
Total   20      100.0   100.0


* tarpos * ovlappos Crosstabulation*
Count

        ovlappos        Total
1       2       3       1
tarpos  1       2       2       2       6
2       3       2       2       7
3       3       2       2       7
Total   8       6       6       20


* to_pos1 * tarpos * ovlappos Crosstabulation*
Count ovlappos

        tarpos  Total
1       2       3       1
1       to_pos1         -1      0       3       3       6
0       1       0       0       1
1       1       0       0       1
Total   2       3       3       8
2       to_pos1         -1      0       2       2       4
0       0       0       0       0
1       2       0       0       2
Total   2       2       2       6
3       to_pos1         -1      0       2       2       4
0       0       0       0       0
1       2       0       0       2
Total   2       2       2       6


* to_pos2 * tarpos * ovlappos Crosstabulation*
Count ovlappos

        tarpos  Total
1       2       3       1
1       to_pos2         -1      2       0       3       5
0       0       2       0       2
1       0       1       0       1
Total   2       3       3       8
2       to_pos2         -1      2       0       2       4
0       0       0       0       0
1       0       2       0       2
Total   2       2       2       6
3       to_pos2         -1      2       0       2       4
0       0       1       0       1
1       0       1       0       1
Total   2       2       2       6


* to_pos3 * tarpos * ovlappos Crosstabulation*
Count ovlappos

        tarpos  Total
1       2       3       1
1       to_pos3         -1      2       3       0       5
0       0       0       1       1
1       0       0       2       2
Total   2       3       3       8
2       to_pos3         -1      2       2       0       4
0       0       0       1       1
1       0       0       1       1
Total   2       2       2       6
3       to_pos3         -1      2       2       0       4
0       0       0       0       0
1       0       0       2       2
Total   2       2       2       6


Art Kendall
Social Research Consultants

eblange wrote:

> Dear Richard,
>
> thanks you for your reply. I decided that the problem has maybe to do with a
> bug on the installation CD. It is replicable on other PCs with the same
> version, and also with different ways to write IF commands (e.g., DO IF...
> ELSE IF). But nevertheless, if you would like to take a look at it would be
> nice.
>
> input data (excerpt):
>
> vpnr    trial   cvc11   cvc12   cvc13   cvc21   cvc22   cvc23   cvc31   cvc32   cvc33   tarpos
> ovlappos
> 1       1       1       1       1       0       0       0       0       1       1       2       1
> 1       2       1       1       1       1       1       1       1       1       1       1       2
> 1       3       0       0       0       0       0       0       0       1       1       1       1
> 1       4       1       1       1       1       1       1       1       1       0       1       3
> 1       5       1       1       1       1       0       1       1       1       1       3       3
> 1       6       0       0       0       0       0       1       0       0       0       3       1
> 1       7       1       1       1       1       1       1       1       1       1       2       3
> 1       8       1       1       1       0       1       0       0       0       0       2       2
> 1       9       0       0       0       0       0       0       0       0       0       3       2
> 1       10      0       0       0       1       1       1       1       1       1       3       2
> 1       11      0       0       0       1       1       0       1       1       0       2       3
> 1       12      1       1       1       1       1       1       1       1       1       1       1
> 1       13      1       1       1       1       1       1       1       1       1       3       3
> 1       14      1       1       0       1       1       1       0       1       0       2       1
> 1       15      0       1       1       0       0       0       1       1       1       1       2
> 1       16      1       1       1       1       1       1       1       1       1       3       1
> 1       17      0       0       0       1       1       0       0       1       0       2       2
> 1       18      1       1       1       1       1       1       1       1       1       1       3
> 1       19      0       1       1       0       1       1       1       1       1       2       1
> 1       20      1       1       1       1       1       1       1       1       1       3       1
>
>
> output: The syntax should create 3 more variables (to_pos1 ..t_pos3) that
> show either a missing value (for two of them) or a rewritten value from the
> input CVC11 to CVC33. What I get is
> a) sometimes all three variables get an input value, sometimes all three the
> same, sometimes different.
> b) sometimes the value has no obvious relation to the input (e.g. 0.5 istead
> of 1 or 0)
> c) sometimes everything looks alright, that is in maybe 1 out of 10 cases.
>
> warning messages? Not at all!
>
> Cheers,
> Elke
>
>
> --
> View this message in context: http://www.nabble.com/SPSS-15-syntax-IF-command-bug--tf3685036.html#a10345245
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

eblange
Below is what I get with my syntax. One problems seems to be the missing values. When I define the variables first (compute to_pos1=-1) as Art suggests, then do the shovelling, and then set the minus 1 to missing, it works. The results of Art are exactly what I want. Still, this sensitivity of SPSS to missing values is new to me, so it might be good to spread this information around a bit.
Thanks to all,
Elke

gettingA gettingA gettingA gettingB gettingB gettingB
1        2        3        1        2        3           want1    want2    want3

       .        0        .        0        0        0        .        0        .
       1        .        .        1        1        1        1        .        .
       0        .        .        0        0        0        0        .        .
       1        .        .        1        0        0        1        .        .
       1        1        1        1        1        1        .        .        1
       0        0        0        0        0        0        .        .        0
       .        1        .        1        1        1        .        1        .
       .        1        .        0        1        0        .        1        .
       0        0        0        0        0        0        .        .        0
       1        1        1        1        1        1        .        .        1
       .        0        .        0        0        0        .        0        .
       1        .        .        1        1        1        1        .        .
       1        1        1        1        1        1        .        .        1
       .        1        .        0        1        0        .        1        .
       1        .        .        1        1        1        1        .        .
       1        1        1        1        1        1        .        .        1
       .        1        .        1        1        1        .        1        .
       1        .        .        1        1        1        1        .        .
       .        0        .        1        0        1        .        0        .
       1        1        1        1        1        1        .        .        1


Number of cases read:  20    Number of cases listed:  20


Art Kendall-2 wrote
In version 15 I used this syntax and got the tables below the syntax.
They show 6, 7, and 7 valid values for To_pos1 to to_pos3 corresponding
to the number of cases with 1,2 an3 for tarpos.

If this still shows the problem you are describing please add 6 more
variables to the example data.

getting1 to getting3 to show what you are getting on your system.
want1 to want3  to show what you want in to_pos1 to to_pos3.

You can get what I am asking for by manually adding want1 to want3,
doing a LIST, cut-and-paste to an email
and then editing the names of to_pos variables

data list list/vpnr (f1)    trial(f2)
   cvc11   cvc12   cvc13
   cvc21   cvc22   cvc23
   cvc31   cvc32   cvc33
   tarpos ovlappos (11f1).
begin data
1   1   1   1   1   0   0   0   0   1   1   2   1
1   2   1   1   1   1   1   1   1   1   1   1   2
1   3   0   0   0   0   0   0   0   1   1   1   1
1   4   1   1   1   1   1   1   1   1   0   1   3
1   5   1   1   1   1   0   1   1   1   1   3   3
1   6   0   0   0   0   0   1   0   0   0   3   1
1   7   1   1   1   1   1   1   1   1   1   2   3
1   8   1   1   1   0   1   0   0   0   0   2   2
1   9   0   0   0   0   0   0   0   0   0   3   2
1   10  0   0   0   1   1   1   1   1   1   3   2
1   11  0   0   0   1   1   0   1   1   0   2   3
1   12  1   1   1   1   1   1   1   1   1   1   1
1   13  1   1   1   1   1   1   1   1   1   3   3
1   14  1   1   0   1   1   1   0   1   0   2   1
1   15  0   1   1   0   0   0   1   1   1   1   2
1   16  1   1   1   1   1   1   1   1   1   3   1
1   17  0   0   0   1   1   0   0   1   0   2   2
1   18  1   1   1   1   1   1   1   1   1   1   3
1   19  0   1   1   0   1   1   1   1   1   2   1
1   20  1   1   1   1   1   1   1   1   1   3   1
end data.
*intialize result variables so we can see what falls through the "sieve".
* and to avoid the use of system missing.
numeric to_pos1 to to_pos3 (f1).
compute to_pos1 = -1.
compute to_pos2 = -1.
compute to_pos3 = -1.
* begin original transformations.
if (tarpos eq 1 and ovlappos eq 1) to_pos1=cvc11.
if (tarpos eq 1 and ovlappos eq 2) to_pos1=cvc12.
if (tarpos eq 1 and ovlappos eq 3) to_pos1=cvc13.

if (tarpos eq 2 and ovlappos eq 1) to_pos2=cvc21.
if (tarpos eq 2 and ovlappos eq 2) to_pos2=cvc22.
if (tarpos eq 2 and ovlappos eq 3) to_pos2=cvc23.

if (tarpos eq 3 and ovlappos eq 1) to_pos3=cvc31.
if (tarpos eq 3 and ovlappos eq 2) to_pos3=cvc32.
if (tarpos eq 3 and ovlappos eq 3) to_pos3=cvc33.
* end original transformations.
frequencies vars = to_pos1 to to_pos3.
crosstabs
  /variables = tarpos ovlappos (1,3) to_pos1 to to_pos3 (-1,1)
  /tables= tarpos by ovlappos
  /to_pos1 to to_pos3 by tarpos by ovlappos
  /missing=report.
* to_pos1*

        Frequency       Percent         Valid Percent   Cumulative Percent
Valid   -1      14      70.0    70.0    70.0
0       1       5.0     5.0     75.0
1       5       25.0    25.0    100.0
Total   20      100.0   100.0


* to_pos2*

        Frequency       Percent         Valid Percent   Cumulative Percent
Valid   -1      13      65.0    65.0    65.0
0       3       15.0    15.0    80.0
1       4       20.0    20.0    100.0
Total   20      100.0   100.0


* to_pos3*

        Frequency       Percent         Valid Percent   Cumulative Percent
Valid   -1      13      65.0    65.0    65.0
0       2       10.0    10.0    75.0
1       5       25.0    25.0    100.0
Total   20      100.0   100.0


* tarpos * ovlappos Crosstabulation*
Count

        ovlappos        Total
1       2       3       1
tarpos  1       2       2       2       6
2       3       2       2       7
3       3       2       2       7
Total   8       6       6       20


* to_pos1 * tarpos * ovlappos Crosstabulation*
Count ovlappos

        tarpos  Total
1       2       3       1
1       to_pos1         -1      0       3       3       6
0       1       0       0       1
1       1       0       0       1
Total   2       3       3       8
2       to_pos1         -1      0       2       2       4
0       0       0       0       0
1       2       0       0       2
Total   2       2       2       6
3       to_pos1         -1      0       2       2       4
0       0       0       0       0
1       2       0       0       2
Total   2       2       2       6


* to_pos2 * tarpos * ovlappos Crosstabulation*
Count ovlappos

        tarpos  Total
1       2       3       1
1       to_pos2         -1      2       0       3       5
0       0       2       0       2
1       0       1       0       1
Total   2       3       3       8
2       to_pos2         -1      2       0       2       4
0       0       0       0       0
1       0       2       0       2
Total   2       2       2       6
3       to_pos2         -1      2       0       2       4
0       0       1       0       1
1       0       1       0       1
Total   2       2       2       6


* to_pos3 * tarpos * ovlappos Crosstabulation*
Count ovlappos

        tarpos  Total
1       2       3       1
1       to_pos3         -1      2       3       0       5
0       0       0       1       1
1       0       0       2       2
Total   2       3       3       8
2       to_pos3         -1      2       2       0       4
0       0       0       1       1
1       0       0       1       1
Total   2       2       2       6
3       to_pos3         -1      2       2       0       4
0       0       0       0       0
1       0       0       2       2
Total   2       2       2       6


Art Kendall
Social Research Consultants

eblange wrote:
> Dear Richard,
>
> thanks you for your reply. I decided that the problem has maybe to do with a
> bug on the installation CD. It is replicable on other PCs with the same
> version, and also with different ways to write IF commands (e.g., DO IF...
> ELSE IF). But nevertheless, if you would like to take a look at it would be
> nice.
>
> input data (excerpt):
>
> vpnr    trial   cvc11   cvc12   cvc13   cvc21   cvc22   cvc23   cvc31   cvc32   cvc33   tarpos
> ovlappos
> 1       1       1       1       1       0       0       0       0       1       1       2       1
> 1       2       1       1       1       1       1       1       1       1       1       1       2
> 1       3       0       0       0       0       0       0       0       1       1       1       1
> 1       4       1       1       1       1       1       1       1       1       0       1       3
> 1       5       1       1       1       1       0       1       1       1       1       3       3
> 1       6       0       0       0       0       0       1       0       0       0       3       1
> 1       7       1       1       1       1       1       1       1       1       1       2       3
> 1       8       1       1       1       0       1       0       0       0       0       2       2
> 1       9       0       0       0       0       0       0       0       0       0       3       2
> 1       10      0       0       0       1       1       1       1       1       1       3       2
> 1       11      0       0       0       1       1       0       1       1       0       2       3
> 1       12      1       1       1       1       1       1       1       1       1       1       1
> 1       13      1       1       1       1       1       1       1       1       1       3       3
> 1       14      1       1       0       1       1       1       0       1       0       2       1
> 1       15      0       1       1       0       0       0       1       1       1       1       2
> 1       16      1       1       1       1       1       1       1       1       1       3       1
> 1       17      0       0       0       1       1       0       0       1       0       2       2
> 1       18      1       1       1       1       1       1       1       1       1       1       3
> 1       19      0       1       1       0       1       1       1       1       1       2       1
> 1       20      1       1       1       1       1       1       1       1       1       3       1
>
>
> output: The syntax should create 3 more variables (to_pos1 ..t_pos3) that
> show either a missing value (for two of them) or a rewritten value from the
> input CVC11 to CVC33. What I get is
> a) sometimes all three variables get an input value, sometimes all three the
> same, sometimes different.
> b) sometimes the value has no obvious relation to the input (e.g. 0.5 istead
> of 1 or 0)
> c) sometimes everything looks alright, that is in maybe 1 out of 10 cases.
>
> warning messages? Not at all!
>
> Cheers,
> Elke
>
>
> --
> View this message in context: http://www.nabble.com/SPSS-15-syntax-IF-command-bug--tf3685036.html#a10345245
> Sent from the SPSSX Discussion mailing list archive at Nabble.com.
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: SPSS 15 syntax IF command bug?

Art Kendall-2
Sometimes the treatment of missing values can be confusing.  However,
SPSS's missing values handling is one of its advantages over other packages.
First, having many different possible missing values, enables you to
treat them differently. This also helps clarify to others what your data
means.

The distinction between user missing and system missing values is very
useful. They occur under two sets of circumstances

1) when the system (i.e., SPSS) cannot read input data according to
your  instructions (syntax).
2) when the system cannot follow your instructions e.g, square root of a
negative number or boolean logic where one or more arguments are not
available.


*However, the existence of system-missing values in your data should
only be a temporary situation.
*They are very useful for debugging your data and syntax.  You can use
them to tell you what you should clarify to yourself about your approach.
*Before you begin any analysis you should aim to have NO system-missing
values in your data.*

If input data is simply blank on input you can get rid of system-missing
values via something like:
set blanks = -9999.
. . . [bring the data in.]
missing values varlist (lo thru 9000).
add value labels varlist  -9999 'input blank'.

When the values are system-missing because SPSS cannot follow your
instructions (syntax) about reading the data, you should go back and fix
your syntax.
If you cannot do that, before you do any you should at least recode all
system-missing values to a values that is outside the range of
legitimate values and inside your range of missing values.
e.g.,
recode varlist (sysmis= -9998).
add value labels varlist -9998 'unreadable input'.

During the transformations phase, many system-missing values can be
eliminating by initializing variables with a user-missing value.
numeric whatever (f1).
compute whatever= -9997.
add value labels whatever  -9997 'not assigned a value while getting
scores'.

Art Kendall
Social Research Consultants



eblange wrote:

> Below is what I get with my syntax. One problems seems to be the missing
> values. When I define the variables first (compute to_pos1=-1) as Art
> suggests, then do the shovelling, and then set the minus 1 to missing, it
> works. The results of Art are exactly what I want. Still, this sensitivity
> of SPSS to missing values is new to me, so it might be good to spread this
> information around a bit.
> Thanks to all,
> Elke
>
> <snip>
>