Example codebook¶
The following files are put together in a zip file or a directory.
Index file¶
codebook.csv
:
variable name,variable label
city,City
sex,Sex
age,Age in single years
age_10,Age in 10 year bands
Variable files¶
city.csv
:
city code,city label
0,London
1,Liverpool
2,Belfast
sex.csv
:
sex code,sex label
M,Male
F,Female
age.csv
:
age code,age label
0,Aged 0 years
...
79,Aged 79 years
80,Aged 80-89 years
90,Aged 90 or over
Note that the “...
” notation causes Cantabular to generate all the intervening categories.
Mapping files¶
The following is the variable file for a mapping.
age_10.csv
:
age_10 code,age_10 label
0-9,Aged 0-9 years
10-19,Aged 10-19 years
20-29,Aged 20-29 years
30-39,Aged 30-39 years
40-49,Aged 40-49 years
50-59,Aged 50-59 years
60-69,Aged 60-69 years
70-79,Aged 70-79 years
80+,Aged 80 years or over
This following file describes the map from the age variable to the age_10 variable.
age_10.mapping.csv
:
age code,age_10 code
0>9,0-9
10>19,10-19
20>29,20-29
30>39,30-39
40>49,40-49
50>59,50-59
60>69,60-69
70>79,70-79
80>90,80+
The greater than sign ( >
) indicates a range or codes in the original variable.
Using the range notation is equivalent to enumerating all the source codes individually. This can be seen in the equivalent mapping file below.
This equivalent mapping file shows the 0-9 and 10-19 mapping codes specified by enumerating all the source codes individually. The other mapping codes could be similarly specified with a full enumeration, but are not in this example in order to keep it shorter.
age_10.mapping.csv
:
age code,age_10 code
0,0-9
1,0-9
2,0-9
3,0-9
4,0-9
5,0-9
6,0-9
7,0-9
8,0-9
9,0-9
10,10-19
11,10-19
12,10-19
13,10-19
14,10-19
15,10-19
16,10-19
17,10-19
18,10-19
19,10-19
20>29,20-29
30>39,30-39
40>49,40-49
50>59,50-59
60>69,60-69
70>79,70-79
80>90,80+
The mapping file could also be specified as follows. The *,80+
line specifies a default mapping with
all otherwise unmapped codes in the source variable mapped to 80+
.
age_10.mapping.csv
:
age code,age_10 code
0>9,0-9
10>19,10-19
20>29,20-29
30>39,30-39
40>49,40-49
50>59,50-59
60>69,60-69
70>79,70-79
*,80+
Microdata¶
Example microdata file which uses the above example codebook:
city,sex,age
0,M,20
0,F,19
In the above example, there are two persons, both in London, one 19 year old male and one 20 year old female.