|
I'm writing some code in v16 and can't figure out why it's not working. Could you tell me why the very last part (where I add q61-q64 together) is not adding up to something other than missing???
COMPUTE Q6CORRECT=0. IF Havecalcium = 'Chicken' Q6Correct=1. If any(Havecalcium1OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q61=1. if any(Havecalcium2OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q62=1. if any(Havecalcium3OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q63=1. if any(Havecalcium4OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q64=1. fre q61 q62 q63 q64. compute q6=q61+q62+q63+q64. execute. fre q6. I don't get it. Q61 thru q64 are numeric, so I should be able to add 1+1+1+1=4 right?? Thanks, Doug Doug Ritenour Maternal and Child Health Epidemiology Specialist II Arizona Department of Health Services Bureau of Women's and Children's Health 150 N. 18th Avenue, Suite 320 Phoenix, AZ 85007 (602) 364-1433 Fax (602) 364-1496 ________________________________ CONFIDENTIALITY NOTICE NOTICE: This E-mail is the property of the Arizona Department of Health Services and contains information that may be PRIVILEGED, CONFIDENTIAL or otherwise exempt from disclosure by applicable law. It is intended only for the person(s) to whom it is addressed. If you receive this communication in error, please do not retain or distribute it. Please notify the sender immediately by E-mail at the address shown above and delete the original message. Thank you. ====================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 |
|
Looks like you are manually trying to do what the COUNT command does. I'm guessing the basic problem is your result is always sysmis, because if any of the four variables is sysmis for a given case, then adding the four values together is going to result in sysmis. You could set q61-q64 to 0 prior to the series of IF statements, or you could use SUM.1(q61, q62, q63, q64) instead of q61+q62+q63+q64 -- or you could use COUNT, as in:
COUNT q6=havecalcium1old, havecalcium2old, havecalcium3old, havecalcium4old ('Dark green leavy vegetables', 'Yogurt', 'Beans'). Also note that string values are case-sensitive. -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Douglas Ritenour Sent: Wednesday, August 20, 2008 11:32 AM To: [hidden email] Subject: compute variable I'm writing some code in v16 and can't figure out why it's not working. Could you tell me why the very last part (where I add q61-q64 together) is not adding up to something other than missing??? COMPUTE Q6CORRECT=0. IF Havecalcium = 'Chicken' Q6Correct=1. If any(Havecalcium1OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q61=1. if any(Havecalcium2OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q62=1. if any(Havecalcium3OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q63=1. if any(Havecalcium4OLD, 'Dark green leavy vegetables', 'Yogurt', 'Beans') q64=1. fre q61 q62 q63 q64. compute q6=q61+q62+q63+q64. execute. fre q6. I don't get it. Q61 thru q64 are numeric, so I should be able to add 1+1+1+1=4 right?? Thanks, Doug Doug Ritenour Maternal and Child Health Epidemiology Specialist II Arizona Department of Health Services Bureau of Women's and Children's Health 150 N. 18th Avenue, Suite 320 Phoenix, AZ 85007 (602) 364-1433 Fax (602) 364-1496 ________________________________ CONFIDENTIALITY NOTICE NOTICE: This E-mail is the property of the Arizona Department of Health Services and contains information that may be PRIVILEGED, CONFIDENTIAL or otherwise exempt from disclosure by applicable law. It is intended only for the person(s) to whom it is addressed. If you receive this communication in error, please do not retain or distribute it. Please notify the sender immediately by E-mail at the address shown above and delete the original message. Thank you. ======= 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 |
| Free forum by Nabble | Edit this page |
