{Application 'POPSTANCENSUSTABLES' logic file generated by CSPro}
PROC GLOBAL

PROC TABLE1
{Generated Code}
Tally
CROSSTAB TABLE1 P02_REL_VS1, P03_SEX_VS1
STAT P02_REL_VS1 (TOTAL, FREQ) P03_SEX_VS1 (TOTAL, FREQ) 
UNIT (P02_REL_VS1 by P03_SEX_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

PROC TABLE10
{Generated Code}
Tally
CROSSTAB TABLE10 P19_LIVING_VS1, P05_MS_VS1
STAT P19_LIVING_VS1 (FREQ, MEDIAN(CONTINUOUS), MEAN) P05_MS_VS1 (TOTAL, FREQ) 
UNIT (P19_LIVING_VS1 by P05_MS_VS1) PERSON
 WEIGHTED BY WEIGHT
 SELECT P03_SEX = 2 and P04_AGE >= 12
ENDUNIT 
;

PROC TABLE11
{Generated Code}
Tally
CROSSTAB TABLE11 COMPLETE_PLUMBING_VS1, UR_VS1
STAT COMPLETE_PLUMBING_VS1 (TOTAL, FREQ) UR_VS1 (TOTAL, FREQ) 
UNIT (COMPLETE_PLUMBING_VS1 by UR_VS1) QUEST
 WEIGHTED BY WEIGHT
TABLOGIC 
 // Fill in complete plumbing based on values
 // of toilet, water and bath.
 if H08_TOILET = 1 and H09_BATH = 1 and H10_WATER = 1 then
 	COMPLETE_PLUMBING = 1; // complete
 elseif H08_TOILET = 1 or H09_BATH = 1 or H10_WATER = 1 then
 	COMPLETE_PLUMBING = 2; // some but not all
 else
 	COMPLETE_PLUMBING = 3; // none
 endif;
ENDLOGIC 
ENDUNIT 
;

PROC TABLE12
{Generated Code}
Tally
CROSSTAB TABLE12 CHILDREN_DECEASED_SINCE_BIRTI, P05_MS_VS1
STAT CHILDREN_DECEASED_SINCE_BIRTI (TOTAL, FREQ) P05_MS_VS1 (TOTAL, FREQ) 
UNIT (CHILDREN_DECEASED_SINCE_BIRTI by P05_MS_VS1) PERSON
 WEIGHTED BY WEIGHT
 SELECT P03_SEX = 2 and P04_AGE >= 12
TABLOGIC 
 CHILDREN_DECEASED_SINCE_BIRTH = P18_BORN - P19_LIVING;
ENDLOGIC 
ENDUNIT 
;

PROC TABLE13
{Generated Code}
Tally
CROSSTAB TABLE13 P04_AGE_VS3, P03_SEX_RATIO_VS2
STAT P04_AGE_VS3 (TOTAL, FREQ) P03_SEX_RATIO_VS2 (TOTAL, FREQ) 
UNIT (P04_AGE_VS3 by P03_SEX_RATIO_VS2) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

PostCalc
// Divide male by female
TABLE13[*, 3] = TABLE13[*,1]/TABLE13[*,2];

PROC TABLE14
{Generated Code}
Tally
CROSSTAB TABLE14 P04_AGE_VS3, P05_MS_VS1 + MARRIED_UNMARRIED_RATIO_VS1
STAT P04_AGE_VS3 (TOTAL, FREQ) P05_MS_VS1 (TOTAL, FREQ)
MARRIED_UNMARRIED_RATIO_VS1 (FREQ) 
UNIT (P04_AGE_VS3 by P05_MS_VS1) PERSON
 WEIGHTED BY WEIGHT
 SELECT P04_AGE >= 10
ENDUNIT 

UNIT (P04_AGE_VS3 by MARRIED_UNMARRIED_RATIO_VS1) PERSON
 WEIGHTED BY WEIGHT
 SELECT P04_AGE >= 10
ENDUNIT 
;

PostCalc
TABLE14[*,6]=TABLE14[*,1]/(TABLE14[*,2]+TABLE14[*,3]+TABLE14[*,4]+TABLE14[*,5]);
PROC TABLE2
{Generated Code}
Tally
CROSSTAB TABLE2 P04_AGE_VS2, P03_SEX_VS1
STAT P04_AGE_VS2 (TOTAL, FREQ) P03_SEX_VS1 (TOTAL, FREQ) 
UNIT (P04_AGE_VS2 by P03_SEX_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

PROC TABLE3
{Generated Code}
Tally
CROSSTAB TABLE3 P05_MS_VS1 + P07_BIRTH_VS1, P03_SEX_VS1 *  (P11_LITERACY_VS1) 
STAT P05_MS_VS1 (TOTAL, FREQ)
P07_BIRTH_VS1 (TOTAL, FREQ) P03_SEX_VS1 (TOTAL, FREQ)
P11_LITERACY_VS1 (TOTAL, FREQ) 
UNIT (P05_MS_VS1 by P03_SEX_VS1*P11_LITERACY_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 

UNIT (P07_BIRTH_VS1 by P03_SEX_VS1*P11_LITERACY_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

PROC TABLE4
{Generated Code}
Tally
CROSSTAB TABLE4 P04_AGE_VS3, P11_LITERACY_VS1
STAT P04_AGE_VS3 (TOTAL, FREQ) P11_LITERACY_VS1 (TOTAL, FREQ) 
UNIT (P04_AGE_VS3 by P11_LITERACY_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

PROC TABLE5
{Generated Code}
Tally
CROSSTAB TABLE5 P04_AGE_VS3, P11_LITERACY_VS1
STAT P04_AGE_VS3 (TOTAL, FREQ) P11_LITERACY_VS1 (TOTAL, FREQ) 
UNIT (P04_AGE_VS3 by P11_LITERACY_VS1) PERSON
 WEIGHTED BY WEIGHT
 SELECT P03_SEX=2 and P04_AGE >= 10
ENDUNIT 
;

PROC TABLE6
{Generated Code}
Tally
CROSSTAB TABLE6 P06_MOTHER_VS1, P03_SEX_VS1
STAT P06_MOTHER_VS1 (TOTAL, FREQ) P03_SEX_VS1 (TOTAL, FREQ) 
UNIT (P06_MOTHER_VS1 by P03_SEX_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

PROC TABLE8
{Generated Code}
Tally
CROSSTAB TABLE8 P02_REL_VS1, P03_SEX_VS1
STAT P02_REL_VS1 (TOTAL, TOTAL(PCT(Row)), FREQ, PCT(Row)) P03_SEX_VS1 (TOTAL, FREQ) 
UNIT (P02_REL_VS1 by P03_SEX_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

PROC TABLE9
{Generated Code}
Tally
CROSSTAB TABLE9 P02_REL_VS1, P03_SEX_VS1
STAT P02_REL_VS1 (TOTAL, TOTAL(PCT(Row)), FREQ, PCT(Row)) P03_SEX_VS1 (TOTAL, FREQ) 
UNIT (P02_REL_VS1 by P03_SEX_VS1) PERSON
 WEIGHTED BY WEIGHT
ENDUNIT 
;

