When determining the indices to use for particular rows and columns, always remember that the first row or column is at index zero and that caption rows (rows with no data) should be skipped. Also note that hidden data rows and columns should be counted even if they are not visible in the table. Always make sure that view hidden parts is turned on when determining row and column indices.
For example, in the table above, in order to calculate the percentage of people in each sex category (Male, Female, Total), we set the values in rows 3, 7 and 9. The caption rows, "Sex", "Total", "Literacy", "Male", and "Female" are not counted, but the hidden rows, the three "Illiterate" rows, are counted. The postcalc logic follows:
TABLE2[3, *] = 100 * TABLE2[1, *] / TABLE2[0, *]; // % literate Total
TABLE2[7, *] = 100 * TABLE2[5, *] / TABLE2[4, *]; // % literate Male
TABLE2[11, *] = 100 * TABLE2[9, *] / TABLE2[8, *]; // % literate Female
When a table includes percents, the row and column indices are a bit more complicated. Although the percent rows/columns are interleaved with the rows/columns for the counts, the percent rows/columns are numbered after the counts. In other words the index for the first percent row or column in a subtable always starts after the last count row or column. For example, in the table below, the rows for the values of marital status under the male caption are counted one after another as indices 0 through 4 and are then followed by the percent rows for marital status as indices 5 through 9. The first percent row is at index 5 which follows the last count row (Never Married) at index 4.
In this example, to calculate the ratio of unmarried men per 100 unmarried women, we need to divide the number of unmarried men (divorced men + separated men + widowed men + never married men) by the number of unmarried women (divorced women + separated women + widowed women + never married women) and multiply the result by 100. The postcalc logic is therefore:
TABLE3[20, *] = 100 * ( TABLE3[1, *] + TABLE3[2, *] + TABLE3[3, *] + TABLE3[4, *] ) /
( TABLE3[11, *] + TABLE3[12, *] + TABLE3[13, *] + TABLE3[14, *] );