TRAN

Purpose

Specifies transformations to be carried out as data are input or during data analysis.

Syntax

TRAN { transformation statement } {; transformation statement ...} @

Arguments and Subcommands

transformation statement

Defines the transformation of a variable or a named constant (see the discussion of the CONSTANT command for more information on named constants). A single TRAN command may include multiple statements separated by semicolons. With the exception of IF and DOWHILE statements, a transformation statement must include an assignment that may define new variables or named constants. In transformations defined prior to the INPUT command, the DELETE function may be used to delete records as the data are read. This function is ignored if used in transformations specified after data have been read. A detailed description of the syntax for transformations and the available operators and functions is given in Transformations in EPICURE  chapter of the Command Summary.

Remarks

The TRAN command cannot be used until after input variable names have been defined with either the NAMES or USE commands. Transformations specified prior to the INPUT command are stored for use in editing the data as it is read from disk. Transformations given after the data have been read are carried out as soon as the command delimiter (@) has been read. Syntax is checked as each line is read. If a syntax error is found, all transformations defined with the current TRAN command are ignored. In order to avoid retyping many statements when transformations are being entered directly from the console, it helps to use several TRAN commands when specifying a large number of transformations. However, when working with large files, it is slightly more efficient to carry out several transformations at once since a single pass through the data is made for each TRAN command. If the TRAN command is given with no arguments prior to the INPUT command, any previously stored editing transformations are deleted. As noted above, there is a limit on the workspace available to store transformation code. This limit is not likely to be a problem for transformations defined after the data have been read because one does not usually need to specify a large number of transformations in a single TRAN command. Transformations are usually carried out on all records even if only a subset of the records are being used in the current analyses (as specified with the SELECT command). However, assignments to named constants (see the discussion of the CONSTANT command) are made only for records in the active subset. New variables defined in TRAN transformations are initialized to MISSING.

Examples

a)  To define several new variables, including various functions of age and time and an exposure status indicator (coded 0 if dose is 0 and 1 otherwise):

TRAN ltime = log(time/30); age = agex + time;

 lage = log(age/50); exposed = (dose >= 0)

@

b)  To delete selected records and to define a dose category variable. In order for the DELETE function to work, this command must be given prior to the INPUT command.

TRAN IF dose >= 0 THEN

 dose = dose/100

ELSE

 DELETE

ENDIF;

dgrp = 1 + (dose  0) + (dose >= 1) + (dose >= 2)

@

c)  To define several new variables:

TRAN lt20 = ltime*(agex >= 20) @

TRAN ltime = log(time/30);

IF dose < 0 THEN

 dose = 0;

 nic = 1

ELSE

 nic = 0

ENDIF

@

d)  To create a five level categorical variable. Parentheses are included to remove any uncertainty regarding rules of precedence for operations.

TRAN dsgrp = 1+(dose > 0) + (dose >= 10) + (dose >= 20) +
    (dose >= 30) @

LEVELS dsgrp @

e)  To modify entry date based upon a sequence number indicator using named constants to preserve values from one record to the next. Named constants are defined and described in the CONSTANT command section.

CONSTANT #inyr = -1 #inmo = -1 #indy = -1 @

TRAN IF seqno == 0 then

 #inyr = -1; #inmo = -1; #indy = -1;

ELIF seqno == 1 then

 #inyr = inyr; #inmo = inmo; #indy = indy;

ELSE

 inyr = #inyr; inmo = #inmo; indy = #indy;

 #inyr = -1; #inmo = -1; #indy = -1;

ENDIF

f)  To define several arrays and use these arrays in a loop which computes cumulative doses at specified times. It is necessary to define the cdose variables before they can be added to an array. Arrays are defined anddescribed in the ARRAY command section.

! Initialize the dose variables

TRAN cdose1 = cdose2 = cdose3 = 0 @

! Define the time, rate, and dose arrays

ARRAY \times time1 time2 time3 @

ARRAY \rates rate1 - rate3 @

ARRAY \cdose cdose1 cdose2 cdose3 zero @

! Compute the cumulative dose values

TRAN #i = 2;

cdose1 = time1*rate1;

DOWHILE (#i <= 3);

\cdose(#i) = \cdose(#i-1) + \times(#i)_\rate(#i)

#i = #i + 1;

ENDDO;

@