2. V.2 CSPro Tabulation Application
Slide presentations were developed by
Philippine Statistical Research and Training Institute and
Philippine Statistics Authority.
2
5. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
▪ In some cases, there is a need to do additional processing on tables after
all the tabulation is completed such as calculate ratios or sums using the
tabulated data.
▪ CSPro allows you to do this by adding program logic in the PostCalc
section of the Tally Attributes (Table) dialog.
▪ Use program logic to access and modify the cells in a table.
▪ In order to use table post calculations to add additional calculations to the
tabulated data, there is a need to insert a place in the table to put these
calculations.
5
6. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
▪ There are two ways to add a new column:
a. Add a new value to the existing value set for the existing variable
b. Drag a new variable onto the table next to the existing one
▪ Adding a new value to the value set creates a new column under the
existing spanner while adding a new variable creates a new column under
a new spanner.
6
7. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
a. Add a new value to the existing value set for the existing variable
• Male/Female Ratio column added as new value to value set for the
variable Sex. The new column is under the Sex spanner.
7
8. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
a. Add a new value to the existing value set for the existing variable
1. Open CSPro 7.7 and select Create a new application.
2. Select Tabulation Application and click OK.
3. Name the .xtb file as sample1 and click Save.
4. Select hpq_dictionary.dcf as <Input dictionary>.
8
9. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
a. Add a new value to the existing
value set for the existing
variable
5. Drag A05_SEX as column item.
6. Click to switch to Data
Dictionary.
7. Modify A05_SEX value set by adding
a new value.
8. Right-click in Window Pane and
select Add Value.
9
10. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
a. Add a new value to the
existing value set for the
existing variable
9. Specify Sex Ratio as Value Label
and 3 for From properties of the
new value.
10. Click to return to Table
application.
The table will be updated to
include Sex Ratio as another
column.
10
11. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
b. By dragging a new variable onto the table
• Male/Female Ratio column added by dragging a new variable onto the
table. The new column is under a separate spanner.
11
12. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Individual Cells
▪ CSPro supports modifying individual cells in a table through PostCalc Logic.
▪ After creating a new column for the calculation, specify PostCalc Logic to
populate the new column.
▪ To access an individual cell in a table, use the table name followed by the indices
of the row and column in parentheses.
▪ Example:
TABLE1(0,3) = TABLE1(0,1) / TABLE1(0,2) * 100;
12
13. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Individual Cells
TABLE1(0,3) = TABLE1(0,1) / TABLE1(0,2) * 100;
13
TABLE
NAME
COLUMN
ROW
14. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Individual Cells
Note that column and row numbers start at zero, so the first column is column
zero, the second column is column is column 1, etc.
14
0
0 1 2 3
Table(0,0) Table(0,1) Table(0,2) Table(0,3)
15. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Individual Cells
▪ To enter PostCalc logic for a table,
open the Tally Attributes (Table)
dialog. Either type the PostCalc logic
directly into the PostCalc area or click
the Edit button next to the PostCalc
area to bring up a larger window to
type in.
▪ Multiple statements may be entered in
PostCalc, provided that each one is
terminated by a semicolon.
15
16. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Rows, Columns and Ranges
▪ 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)*100;
TABLE1(1,3) = TABLE1(1,1) / TABLE1(1,2) *100;
TABLE1(2,3) = TABLE1(2,1) / TABLE1(2,2) *100;
: : :
TABLE1(20,3) = TABLE1(20,1) / TABLE1(20,2) *100;
16
17. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Rows,
Columns and Ranges
▪ As example, in the Sex Ratio table,
add A09_MARITAL_STATUS
as row item.
▪ Click Tally Attributes.
▪ Click opposite PostCalc
section.
17
18. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Rows, Columns and Ranges
▪ Enter the following codes as PostCalc Logic:
TABLE1(0,3) = TABLE1(0,1) / TABLE1(0,2) * 100;
TABLE1(1,3) = TABLE1(1,1) / TABLE1(1,2) * 100;
TABLE1(2,3) = TABLE1(2,1) / TABLE1(2,2) * 100;
TABLE1(3,3) = TABLE1(3,1) / TABLE1(3,2) * 100;
TABLE1(4,3) = TABLE1(4,1) / TABLE1(4,2) * 100;
TABLE1(5,3) = TABLE1(5,1) / TABLE1(5,2) * 100;
TABLE1(6,3) = TABLE1(6,1) / TABLE1(6,2) * 100;
TABLE1(7,3) = TABLE1(7,1) / TABLE1(7,2) * 100;
▪ Click OK.
▪ Click to save and to run.
18
19. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Rows, Columns and Ranges
▪ Another way of coding using a range - 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]*100;
▪ 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.
19
20. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Rows, Columns and Ranges
▪ Another way of coding using a wildcard - use a wildcard (an asterisk) to
specify an entire row or column:
TABLE1[*,3] = TABLE1[*,1] / TABLE1[*,2] * 100;
▪ Using an asterisk in place of the row index means that the operation
applies to all rows in the table.
20
21. V.2 CSPro Tabulation Application
Table Post Calculation (Post Calc)
Post Calculation For Rows, Columns and Ranges
▪ You can only assign ranges or wildcards to each other if the dimensions of
the ranges match.
▪ Example:
TABLE1[0:2, 0:3] = TABLE1[3:5, 0:3];
▪ The above code copies one 3 by 4 region of the table to another 3 by 4
region.
21
22. V.2 CSPro Tabulation Application 22
CSPro Tabulation Application
HP-I1. Average per Capita Weekly Food Consumption Expenditure
by Barangay: Municipality of Sugpon, 2022
EXAMPLE
23. V.2 CSPro Tabulation Application
1. Open CSPro 7.7 and select Create a new application.
2. Select Tabulation Application and click OK.
3. Name the .xtb file as HP-I1 and click Save.
4. Select hpq_dictionary.dcf as <Input dictionary>.
23
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
24. V.2 CSPro Tabulation Application
5. Right-click the Working Storage
Record at the bottom of the Tree
Pane
6. Select Add Item to create two
new items.
• Household
• Indicator
24
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
25. V.2 CSPro Tabulation Application
Refer to the following for the properties of the newly added items:
25
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
26. V.2 CSPro Tabulation Application
7. Add a value set in the created item, Household.
8. Add a value set in the created item, Indicator.
26
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
27. V.2 CSPro Tabulation Application
9. Drag all the newly created variables as column variable.
10. Remove the Total column from the Tally Attributes(variable_name) of
each variable.
27
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
28. V.2 CSPro Tabulation Application
11. Indicate proper Table Title and Footnote.
Table Title:
Average per Capita Weekly Food Consumption Expenditure by Barangay:
Municipality of Sugpon, 2022
Footnote: 2022 Community-Based Monitoring System (CBMS)
28
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
29. V.2 CSPro Tabulation Application
12. Click Tally Attributes.
13. Under the Table (Subtables): Entire Table, specify the universe.
HSN < 7777 and RESULT_OF_VISIT = 1
29
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
30. V.2 CSPro Tabulation Application
14. Next, click the dropdown under the Table (Subtables): and select
SYSTEM_TOTAL by INDICATOR.
15. Then, specify the corresponding codes below:
Value Tallied: I04_TOTAL_FOOD_CONSUMPTION / count(SECTION_A_TO_E
where A02_RELATION_TO_HH_HEAD in 1:23)
Tab Logic: INDICATOR = 2;
PostCalc: TABLE1[*,1] = (TABLE1[*,1] / TABLE1[*,0]) / 52;
30
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
31. V.2 CSPro Tabulation Application
16. Next, click the dropdown
under the Table (Subtables): and
select SYSTEM_TOTAL by
HOUSEHOLD.
17. Then, specify the TabLogic.
HOUSEHOLD = 1;
31
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
32. V.2 CSPro Tabulation Application 32
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
33. V.2 CSPro Tabulation Application
18. Click to specify area.
19. Select Region to Barangay from
the list of Questionnaire Items.
20. Click to add it into the Area
Items box and click OK.
33
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
34. V.2 CSPro Tabulation Application
21. Click to save and to run.
22. Select:
sample_data.csdb as
<Input Data>
RegProvMunBrgy.anm as
<Area Names>
and click OK.
34
HP-I1 Average per Capita Weekly Food Consumption Expenditure by Barangay: Municipality of Sugpon, 2022
35. V.2 CSPro Tabulation Application 35
EXERCISE 12
Tabulate:
HP-I2. Average per Capita Monthly Food Consumption Expenditure by
Barangay: Municipality of Sugpon, 2022