ARRAY

Purpose

Defines arrays for use in transformations that are particularly useful when computing time dependent covariates. It can also be used to display current array definitions.

Syntax

ARRAY  \arrnam vlist @

ARRAY  \arrnam * SIZE nsize  {PREFIX varpfx} {START nfrom} @

ARRAY  \arrnam @

Arguments and Subcommands

\arrnam vlist                       

Defines an array called \arrnam. The array name must begin with a \ to distinguish it from variable and constant names and may be up to eight characters long (including the leading\). vlist defines variables included in the array in the order listed. The total number of elements in all arrays must be less than or equal to 300. vlist may include variables from previously defined arrays and the same name may appear more than once in a single array. However, named constants and arrays may not be included in the vlist.

If an array includes variables in the same order in which they were named or defined, the complete set of variables can be indicated by listing the first and last names separated by a dash (-).

\arrnam * PREFIX varpfx SIZE nsize {START nfrom }

Define an array of new variables with names of the form varpfx#n where #n is a number.

SIZE

Specifies the number of elements in the array.  This is required when defining an array of new variables.

PREFIX

Specifies the prefix for the newly created variables.  If a prefix is not given the array name (arrnam) is used as the variable prefix.

START

Specifies the #n value to be used for the first array element.  This value is incremented by one for each element.  The default value for #n is 1. 

\arrnam

Displays the definition of the array \arrnam. This information is also displayed following the SHOW command.

Remarks

Array index values may be numbers, named constants, or expressions.

For arrays of newly defined variables, an error will be generated if an array element variable already exists.   When an array of newly defined variables is created before the data are read, as is often the case in DATAB command scripts, the user must initialize the array variables. However, if an array of newly defined variables is created after the data have been read, the value of the newly created variables with be initialized to #n.  The user can use transformations to modify the default initial values.

Arrays are dropped using the DROP command. If a variable is currently being used in one or more arrays, the variable cannot be dropped until the array is dropped.

Examples

a)  To define one array called \times which includes variables called zero, time1, time2, time3, and big and a second array called \rates which includes the variables zero, rate1, rate2, rate3, and zero:

ARRAY \times zero time1 time2 time3 big @
ARRAY \rates zero rate1 - rate3 zero @

       Note that the three risk variables are defined by the use of the "-" separator.

b)  To use the arrays defined in the previous example in some transformations. (Code like this might be used in time dependent transformations for the construction of a person year table with cumulative dose categories or in the computation of time dependent covariates in PEANUTS.)

TTRAN #i = 2;

 big = 1e10; zero = 0;

 cdose = 0;

DOWHILE (%time  \times(#i));

 cdose = cdose + \rates(#i)*(\times(#i) - \times(#i-1));

 #i = #i + 1;

ENDDO;

 cdose = cdose + \rates(#i)*(%time - \times(#i-1));

@

c)  To create an array, \yr, of 10 newly-defined variables and initialize the values of these variables.  The newly-created variables will be called y1, y2, … y10.  The new variables values are  explicitly initialzied to the values 1950 1951., 1952, … 1958, and 1960 using the tranformations shown below.

ARRAY \yrs *  SIZE 10 PREFIX y @

TRAN  cons #i = 1 ;
  DOWHILE  #i < 10;:
     \yrs(#i) = 1949+#i
     #i = #i + 1;
  ENDDO;
  y10 = 1960 ;
@

d)  To drop the rates array and display the definitions of all remaining arrays:

DROP \rates @

ARRAY @