In addition to performing operations on individual cells, you can perform operations on cell ranges, rows and columns. As an example, take the following table, in which an additional column is added to calculate the male to female ratio for each group.
The postcalc logic for assigning rows and columns is similar to that of individual cells, however there is a simplified syntax for working with cell ranges, rows and columns. You could set each cell individually with multiple statements as follows:
TABLE1(0, 3) = TABLE1(0, 1) / TABLE1(0, 2);
TABLE1(1, 3) = TABLE1(1, 1) / TABLE1(1, 2);
// ...
TABLE1(2, 3) = TABLE1(2, 1) / TABLE1(2, 2);
TABLE1(20, 3) = TABLE1(20, 1) / TABLE1(20, 2);
However, that would take a lot of code. Instead, you can specify this one statement using a range or a wild card. To use a range, give the lower and upper limits separated by a colon:
TABLE1[0:20, 3] = TABLE1[0:20, 1] / TABLE1[0:20, 2];
This means divide the cell in column 1 by the cell in column 2 and put the result in the cell in column 3 for each row from 0 to 20. You can also use a wildcard (an asterisk) to specify an entire row or column:
TABLE1[*, 3] = TABLE1[*, 1] / TABLE1[*, 2];
Using an asterisk in place of the row index means that the operation applies to all rows in the table. In this case it is the same as specifying the range 0:20 since the table has 21 rows. An asterisk can also be used in place of the column index to specify every column in a table:
TABLE1[1, *] = TABLE1[2, *]; // copy row 2 into row 1
Note that when working with rows, columns and ranges, you must use square brackets "[ ]" rather than parentheses "( )". Parentheses may only be used when specifying individual cells.
You can only assign ranges or wildcards to each other if the dimensions of the ranges match. For example:
TABLE1[0:2, 0:3] = TABLE1[3:5, 0:3];
This copies one 3 by 4 region of the table to another 3 by 4 region. However, the following code will fail since it attempts to copy a 3 by 4 region to a 3 by 3 region:
TABLE1[0:2, 0:2] = TABLE1[3:5, 0:3]; // This does not work !