Date: Fri, 9 Sep 2005 20:15:09 -0400 Reply-To: Richard Ristow Sender: "SPSSX(r) Discussion" From: Richard Ristow Subject: Re: Explaining output of a do if with missing values Comments: To: Martin Sherman In-Reply-To: Content-Type: text/plain; charset="us-ascii"; format=flowed At 09:59 AM 9/9/2005, Martin Sherman wrote: >>I don't understand why if Race eq 3 and sex is missing then racesex >>eq 5, but when sex eq 1 and race is missing then racesex eq missing >>[in the following code, in which indents have been added for clarity]: >> >>. do if (race eq 1 and sex eq 1). >>. compute racesex=1. >>. else if (race eq 1 and sex eq 2). >>. compute racesex=2. >>. else if (race eq 2 and sex eq 1). >>. compute racesex=3. >>. else if (race eq 2 and sex eq 2). >>. compute racesex=4. >>. else. >>. compute racesex=5. >>. end if. Jim Marks: >I guess that the cases with race = 3 are passed along for later >processing, even when sex is missing. Yes, as documented. In this case, "race eq 2" tests 'false', as does "race eq 2". In SPSS logical calculations, "FALSE and MISSING" evaluates 'false', which is logically reasonable(*). If race is 3, all the tests will test 'false'; the ELSE clause will be reached, and 'racesex' assigned value 5. >The cases with race = 1 or 2 and sex missing all fail in the earlier >DO IF/ ELSE IF statements. Again, yes. If sex is missing, "sex eq B" tests 'missing', and no combination "race eq A and sex eq B" can ever test 'true'; see the table below. If race is 1, the first test returns 'missing' and the rest of the DO IF construct is skipped. If race is 2, the first two tests return 'false', the third returns 'missing', and the rest of the DO IF construct is again skipped. In neither case will any of the COMPUTE statements be executed. Now, what do you want to happen? A simple improvement is, compute racesex=9. do if (race eq 1 and sex eq 1). . end if. Then, racesex has value 9 if the DO IF is skipped because a test returns 'missing'. Or, you can specify the outcome for different 'missing' combinations of race and sex by using the MISSING function in tests. But the logic for that depends on what you're wanting to do. Good luck! Richard ...................... From the syntax manual: Table 6 Outcome for AND and OR combinations Combinations with AND: Expression Outcome true AND true = true true AND false = false false AND false = false true AND missing = missing missing AND missing = missing false AND missing = false* Combinations with OR: Expression Outcome true OR true = true true OR false = true false OR false = false true OR missing = true* missing OR missing = missing false OR missing = missing * Expressions where SPSS can evaluate the outcome with incomplete information. See "Missing Values in Logical Expressions".

Back to: Top of message | Previous page | Main SPSSX-L page