missing values in do if

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

missing values in do if

Keval Khichadia
do if num_in_family = 1 & Fisap_Income <= 19600.
compute LowIncome = 1.
else if num_in_family = 2 & Fisap_Income <= 26400.
compute LowIncome = 1.
else if num_in_family = 3 & Fisap_Income <= 33200 .
compute LowIncome = 1.
else if num_in_family = 4 & Fisap_Income <= 40000.
compute LowIncome = 1.
else if num_in_family = 5 & Fisap_Income <= 46800.
compute LowIncome = 1.
else if num_in_family = 6 & Fisap_Income <= 53600.
compute LowIncome = 1.
else if num_in_family = 7 & Fisap_Income <= 60400.
compute LowIncome = 1.
else if num_in_family = 8 & Fisap_Income <= 67200.
compute LowIncome = 1.
else if num_in_family = $sysmis | Fisap_Income = $sysmis.
compute LowIncome = $sysmis.
else.
compute LowIncome = 0.
end if.
When I run this syntax, I am getting the correct value (1) for LowIncome but there are several cases when there are values for num_in_family and Fisap_Income where the value should be 0 but I am getting $sysmis. For example if the value of num in family is 4 and the Fisap_Income is 280000 LowIncome should be 0 but I am getting sysmis.
Any help is appreciated.


      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

=====================
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: missing values in do if

Melissa Ives
Try this... Tested.  LowIncome will be sysmis if either of your variables is missing.

do if num_in_family = 1.
  compute  LowIncome = (Fisap_Income <= 19600).
else if num_in_family = 2.
  compute  LowIncome = (Fisap_Income <= 26400).
else if num_in_family = 3.
  compute  LowIncome = (Fisap_Income <= 33200).
else if num_in_family = 4.
  compute  LowIncome = (Fisap_Income <= 40000).
else if num_in_family = 5.
  compute  LowIncome = (Fisap_Income <= 46800).
else if num_in_family = 6.
  compute  LowIncome = (Fisap_Income <= 53600).
else if num_in_family = 7.
  compute  LowIncome = (Fisap_Income <= 60400).
else if num_in_family = 8.
  compute  LowIncome = (Fisap_Income <= 67200).
end if.
exe.

Melissa

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Keval Khichadia
Sent: Monday, May 12, 2008 12:20 PM
To: [hidden email]
Subject: [SPSSX-L] missing values in do if

do if num_in_family = 1 & Fisap_Income <= 19600.
compute LowIncome = 1.
else if num_in_family = 2 & Fisap_Income <= 26400.
compute LowIncome = 1.
else if num_in_family = 3 & Fisap_Income <= 33200 .
compute LowIncome = 1.
else if num_in_family = 4 & Fisap_Income <= 40000.
compute LowIncome = 1.
else if num_in_family = 5 & Fisap_Income <= 46800.
compute LowIncome = 1.
else if num_in_family = 6 & Fisap_Income <= 53600.
compute LowIncome = 1.
else if num_in_family = 7 & Fisap_Income <= 60400.
compute LowIncome = 1.
else if num_in_family = 8 & Fisap_Income <= 67200.
compute LowIncome = 1.
else if num_in_family = $sysmis | Fisap_Income = $sysmis.
compute LowIncome = $sysmis.
else.
compute LowIncome = 0.
end if.
When I run this syntax, I am getting the correct value (1) for LowIncome but there are several cases when there are values for num_in_family and Fisap_Income where the value should be 0 but I am getting $sysmis. For example if the value of num in family is 4 and the Fisap_Income is 280000 LowIncome should be 0 but I am getting sysmis.
Any help is appreciated.


      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ

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

=====================
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: missing values in do if

Richard Ristow
In reply to this post by Keval Khichadia
At 01:19 PM 5/12/2008, Keval Khichadia wrote:

>[In the following syntax] I get the correct value (1) for LowIncome
>but there are several cases when there are values for num_in_family
>and Fisap_Income where the value should be 0 but I am getting $sysmis
>
>do if num_in_family = 1 & Fisap_Income <= 19600.
>compute LowIncome = 1.
>else if num_in_family = 2 & Fisap_Income <= 26400.
>compute LowIncome = 1.
>else if num_in_family = 3 & Fisap_Income <= 33200 .
>compute LowIncome = 1.
>else if num_in_family = 4 & Fisap_Income <= 40000.
>compute LowIncome = 1.
>else if num_in_family = 5 & Fisap_Income <= 46800.
>compute LowIncome = 1.
>else if num_in_family = 6 & Fisap_Income <= 53600.
>compute LowIncome = 1.
>else if num_in_family = 7 & Fisap_Income <= 60400.
>compute LowIncome = 1.
>else if num_in_family = 8 & Fisap_Income <= 67200.
>compute LowIncome = 1.
>else if num_in_family = $sysmis | Fisap_Income = $sysmis.
>compute LowIncome = $sysmis.
>else.
>compute LowIncome = 0.
>end if.

Your problem is that the final COMPUTE,
>compute LowIncome = 0.
will never be executed.

The value in test
>else if num_in_family = $sysmis | Fisap_Income = $sysmis.
is never 'true', and it's never 'false', either; it's 'missing'. In a
DO IF, if any test returns 'missing', its clause *and all following
clauses* are skipped, with no notification. (Distinguishing between
'false' and 'missing' in tests was one of SPSS's good ideas; treating
'missing' this way in DO IF, and just like 'false' everywhere else,
was one of the bad ones.)

"SYSMIS" is not a value, so nothing can be equal to it.

You want,

else if SYSMIS(num_in_family) | SYSMIS(Fisap_Income).
compute LowIncome = $sysmis.
else.
compute LowIncome = 0.
end if.

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