Transformation and Subset Selection Commands

EPICURE programs allow transformations to recode existing variables or to create new variables at any time while using these programs. Transformations are described with free-format statements which may involve constants, variable names, arithmetic operators (+, - , *, and /), and the exponentiation (^ or, equivalently,**) operator.

Transformation statements can also employ relational or logical operators. Relational operators include EQ, NE, LT, LE, GT, and GE, which may also be written asĀ  ==, /=, <, <=, >, and >=). Logical operators include AND, OR, and NOT. The symbols & and | may be used in place of AND and OR, respectively. Logical expressions are assigned the value 1 if true and 0 if false. Many commonly used functions are available for transformation commands, including: LOG (natural logarithms), EXP, ABS, SIN, COS, FLOOR (the nearest integer less than or equal to the value), and CEILING (the nearest integer greater than or equal to the value). The MOD function calculates the remainder of x divided by y. The MIN and MAX functions evaluate to the minimum and maximum, respectively, of their two arguments. The GL (generate levels) function can be used to define cyclic indices. This function has two arguments. The first argument is an integer that indicates how many levels are to be defined; the second argument indicates the number of times each level is to be repeated before changing to the next level. Thus, the first seven elements of the variable created by the GL(3,2) command would be 1 1 2 2 3 3 1. The arguments for these functions (LOG,EXP,ABS,...GL) may be variables, constants, or other expressions (including other functions).

EPICURE has several random number generators, including uniform(0,1) (RANU(d), where d is an unused dummy argument), normal (0,1) (RANN(d), where d is an unused dummy argument), binomial (RANB(n,p), where n is the number of events and p is the binomial probability), and Poisson (RANP(mu), where mu is the Poisson mean). The arguments to these random number generators can be constants or variables. The underlying generator is the RAN1 generator described by Press et al (1986, pp. 192-200), which makes use of three linear congruential generators. The normal random numbers are generated from U(0,1) variates using the Box-Muller method. Rejection methods are used to generate the binomial and Poisson deviates. These algorithms are also described by Press et al (1986, pp. 99, 200-209).

The operators and functions follow generally accepted precedence rules, with functions at the highest level, followed by exponentiation, multiplication or division, addition or subtraction, relational operators, logical operators, and negation. Assignment (=) is treated as an operator with the lowest precedence (which allows multiple assignments for example, A=B=0). Parentheses may be used to define the order of evaluation when necessary.

IF - THEN - ELIF - ELSE - ENDIF and DOWHILE - ENDDO blocks are allowed. The statement following IF or ELIF is generally a logical expression; however, any syntactically correct expression, including a variable name may be used. The statements following THEN are evaluated if and only if the IF expression is non-zero (true). The statements following ELSE are evaluated if and only if the IF expression is zero (false). There may be several statements after THEN or ELSE. These statements should be separated by semicolons (;). ELIF or ELSE blocks may be omitted. Loops are particularly useful when working with user-defined arrays of variables. DOWHILE loops generally begin with a logical expression (loop test); however, any syntactically correct expression, (including, for example, a variable name) may be used. If the loop test is true, the statements within the loop, that is, prior to the ENDDO command, are executed. The code within the body of the loop is executed until the loop test is false. The user must set up the loop test to eventually become false or the loop will execute indefinitely. If the program enters an infinite loop, it is possible to use the break key (CTRL-C) to cancel the transformations. Several examples illustrating the proper syntax for transformations are given following the descriptions of the TRAN and ARRAY commands.

New variables defined in transformations are initialized to the internal missing value code prior to use. Full details of the transformation functions and syntax can be found in Transformations in EPICURE.