I'm generating a crosstable of one column variable and multiple row variables. I want the percentages of the sub categories of the row variables as crosses with the column variable to be displayed. For example, what percentage of voters between the ages of 18 and 30 are swing voters as against those of the same category that are core voters? When added up, the two percentages should sum up to 100% as I indicated in the last column in the table below. Unfortunately, the fvpercent command is not producing percentages along that line. Instead, the percentages appear to be those of the column variable. Any help? table (var) (swing_voter), statistic(fvpercent age gender marital_status) nototals /// style(Table-1)
Voted for the same party | ||||
core | swing | Total percentage | ||
Age | ||||
18-30 | 31.65 | 26.19 | 100 | |
31-40 | 32.98 | 37.81 | 100 | |
41-50 | 20.04 | 19.55 | 100 | |
51-60 | 11.35 | 11.32 | 100 | |
60+ | 3.98 | 5.13 | 100 | |
Gender | ||||
Male | 49.63 | 51.7 | 100 | |
Female | 50.37 | 48.3 | 100 | |
Marital Status | ||||
unmarried | 37.96 | 36.68 | 100 | |
married | 62.04 | 63.32 | 100 | |
Location of Constituency | ||||
Urban | 50 | 48.3 | 100 | |
Rural | 50 | 51.7 | 100 |
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(swing_voter age gender marital_status) 0 1 1 0 1 4 1 1 0 2 2 1 0 1 2 1 0 1 2 0 1 2 1 1 0 3 2 1 0 5 2 1 0 3 2 1 0 1 1 1 0 2 1 1 1 2 1 0 0 5 2 1 1 3 1 1 0 2 1 0 1 1 2 0 0 4 2 1 0 2 1 0 1 2 2 0 0 3 2 0 0 2 2 1 0 2 2 0 0 2 2 1 0 5 1 1 0 1 1 1 0 4 1 1 1 2 1 0 0 4 1 1 1 2 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 1 2 1 1 0 1 2 0 1 4 1 1 0 2 1 1 1 2 1 1 0 3 1 1 0 1 1 0 0 2 1 1 0 1 2 1 0 2 1 1 0 2 2 0 0 1 1 0 1 1 1 0 1 1 2 0 0 1 2 0 1 4 1 1 1 1 1 0 0 4 1 1 0 3 1 1 0 5 2 1 0 2 1 1 0 3 1 1 0 2 1 1 1 1 2 0 1 2 2 1 1 1 1 0 0 2 2 1 0 1 1 1 0 2 1 1 0 3 1 1 1 1 2 0 0 3 2 0 1 4 1 1 0 5 2 0 0 4 2 1 1 3 1 1 0 2 2 1 1 2 2 0 0 1 2 1 1 1 2 0 1 1 1 0 0 3 1 1 0 2 2 1 1 3 1 1 1 3 2 1 0 2 2 0 0 1 1 0 0 1 2 0 0 4 1 1 0 1 1 0 0 5 1 1 0 2 1 1 1 1 1 0 0 4 1 1 1 2 1 1 0 2 2 1 1 2 2 1 0 1 1 0 1 2 2 0 0 4 2 0 1 4 1 1 0 2 2 0 1 4 1 1 1 2 2 0 0 3 1 1 0 2 1 0 1 1 1 1 end label values swing_voter swingvoter label def swingvoter 0 "core", modify label def swingvoter 1 "swing", modify label values age labels0 label def labels0 1 "18-30", modify label def labels0 2 "31-40", modify label def labels0 3 "41-50", modify label def labels0 4 "51-60", modify label def labels0 5 "60+", modify label values gender labels1 label def labels1 1 "Male", modify label def labels1 2 "Female", modify label values marital_status marriage label def marriage 0 "unmarried", modify label def marriage 1 "married", modify
Comment