Using Operators in a query

P

Philly

I am trying to recode a variable in a query to read:

If Variable is equal to True, give it a 1. If variable is False, give it a
0. If variable is -999, give it a -999. However, I can not get it to work
properly. I am currently writing it like this:

NEWVARIABLE: iif (OLDVARIABLE="True",1) Or iif(OLDVARIABLE="False",0) Or
iif(OLDVARIABLE=-999,-999)

I'm not sure if the operator "Or" is the best one to use in this situation.
Does anyone have a better idea?

Thanks so much!
 
M

MGFoster

Philly said:
I am trying to recode a variable in a query to read:

If Variable is equal to True, give it a 1. If variable is False, give it a
0. If variable is -999, give it a -999. However, I can not get it to work
properly. I am currently writing it like this:

NEWVARIABLE: iif (OLDVARIABLE="True",1) Or iif(OLDVARIABLE="False",0) Or
iif(OLDVARIABLE=-999,-999)

I'm not sure if the operator "Or" is the best one to use in this situation.
Does anyone have a better idea?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Use the Switch() function (all one line):

NewVariable: Switch(OldVariable = "True", 1,
OldVariable = "False", 0,
OldVariable = -999, -999)

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQxdLcYechKqOuFEgEQLWxgCfXqGnLLVbnW46xQZYDcae4PIZDdQAn2PI
j54+iMEzrmoRR/c7ePnyvUCd
=YDph
-----END PGP SIGNATURE-----
 
Top