There are various types of operators discussed in this appendix. The following types are provided:
Operator PrecedenceIf several operations occur in an expression, each part is evaluated and resolved in a predetermined order called Operator Precedence. Parentheses can be used to override the order of precedence and evaluate some parts of an expression before others. Operations within parentheses are always performed before those outside. Within parentheses, however, normal Operator Precedence is maintained. If expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators next, and logical operators last. Comparison operators all have equal precedence; they are evaluated in the left-to-right order in which they appear. Arithmetic and logical operators are evaluated in the following order of precedence:
If addition and subtraction, multiplication and division, occur together respectively in an expression, each operation is evaluated as it occurs from left to right. The string concatenation operator (&) is not an arithmetic operator, but in precedence, it does fall after all arithmetic operators and before all comparison operators. The Is operator is an object reference comparison operator. It does not compare objects or their values; it checks only to determine whether two object references refer to the same object.
Description Syntax
Whenever an expression is not a string, it is converted to a String subtype. If both expressions are Null, the result is Null. However, if only one expression is Null, that expression is treated as a zero-length string (“”) when concatenated with the other expression. Any expression that is Empty is also treated as a zero-length string. Example
READ {.\Projects\Sample\Sample.prj}:Oswego DEFINE FullName TEXTINPUT ASSIGN FullName = LastName & ", " & FirstName LIST LastName FirstName FullName
Description Syntax
Comments Example
READ {.\Projects\Sample\Sample.prj}:Oswego DEFINE Newvar NUMERIC ASSIGN Newvar = Age LIST Newvar Age
Description Syntax Comments
If one or both expressions are Null expressions, the result is Null. If both expressions are Empty, the result is an integer subtype. However, if only one expression is Empty, the other expression is returned unchanged as a result. Example
READ {.ProjectsSampleSample.prj}:Oswego DEFINE Newvar NUMERIC ASSIGN Newvar = Age + 5 LIST Age Newvar
Description Syntax Comments Example
READ {.\Projects\Sample\Sample.prj}:Smoke DEFINE Result TEXTINPUT IF Age > 75 AND Sex = 2 THEN ASSIGN Result="Senior" END SELECT Result = "Senior" LIST Result Age Sex In this case, the value of “Senior” is assigned to all records that meet both criteria Age>75 and Sex=2.
Description Syntax
Comments
Arithmetic operators are shown in descending order of precedence. Parentheses can be used to control the order in which operators are evaluated. The default order, however, frequently achieves the correct result. While it is possible to do date math with dates considered as a number of days (e.g., IncubationDays = SymptomDateTime – ExposureDateTime), the behavior of the database services underlying Epi Info makes it more efficient to use time interval functions (e.g., IncubationDays = MINUTES(ExposureDateTime, Symptom DateTime)/[24*60]). For doing date math, the following rules apply: Date + Date produces Date Date – Date produces Days Date * Date not permitted Date / Date not permitted Date ^ Date not permitted Date + Number produces Date Number + Date produces Number The last two rules apply as well to other math operations: -, *, /, ^ The “zero day” for date math is December 30, 1899. Example
READ {.ProjectsSampleSample.prj}:Surveillance DEFINE var1 NUMERIC ASSIGN var1=1250 MOD 100 DEFINE var2 NUMERIC ASSIGN var2=1+1 DEFINE var3 NUMERIC ASSIGN var3=2-1 DEFINE var4 NUMERIC ASSIGN var4=1*1 DEFINE var5 NUMERIC ASSIGN var5=8/4 DEFINE var6 NUMERIC ASSIGN var6=5^2 LIST var1 var2 var3 var4 var5 var6
Description
Syntax [Expression] <operator> [Expression] [Expression] is any valid expression. Comments Example
READ {.ProjectsSampleSample.prj}:Surveillance SELECT Age>20 LIST Age Disease READ {.ProjectsSampleSample.prj}:Surveillance SELECT Age<45 LIST Age Disease READ {.ProjectsSampleSample.prj}:Surveillance SELECT Age>=38 LIST Age Disease READ {.ProjectsSampleSample.prj}:Surveillance SELECT Age<>77 LIST Age Disease
Description Syntax SELECT <variable> LIKE “*value*” SELECT <variable> LIKE “*val*” SELECT <variable> LIKE “v*” SELECT <variable> LIKE “*v”
Comments Examples
READ {.\Projects\Sample\Sample.prj}:Surveillance DEFINE Sick NUMERIC IF Disease LIKE "h*" THEN ASSIGN Sick = 0 END SELECT Disease LIKE "h*" LIST Age Disease DateAdmitted Sick GRIDTABLE
Description Syntax NOT [Expression] The expression represents any valid logical expression in Epi Info. Comments Example
READ {.ProjectsSampleSample.prj}:Oswego DEFINE NoVanilla YN IF NOT Vanilla = (+) THEN NoVanilla = (+) ELSE NoVanilla = (-) END FREQ NoVanilla Vanilla
Description Syntax [Logical Expression] OR [Logical Expression] [Logical Expression] represents any valid logical expression in Epi Info. Example
READ {.ProjectsSampleSample.prj}:Oswego DEFINE IceCream YN IF VANILLA=(+) OR CHOCOLATE=(+) THEN ASSIGN IceCream=(+) ELSE ASSIGN IceCream=(-) END FREQ IceCream
Description Syntax [Logical Expression] XOR [Logical Expression] The [Logical Expression] represents any valid logical expression in Epi Info 7 for Windows. Comments
Example
READ {.ProjectsSampleSample.prj}:Oswego DEFINE OneIcecream YN IF Vanilla = (+) XOR Chocolate = (+) THEN ASSIGN OneIcecream = (+) ELSE ASSIGN OneIcecream = (-) END LIST Vanilla Chocolate OneIcecream |