-
Notifications
You must be signed in to change notification settings - Fork 0
/
oesch.ado
96 lines (76 loc) · 2.95 KB
/
oesch.ado
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
********************************************************************************
* This is a little helper script to create 8- and 5-class versions of Oesch
* class variables, based on code by Amal Tawfik, University of Geneva
* found at http://people.unil.ch/danieloesch/scripts/
*
*
* see 'help oesch' for more Info
*
********************************************************************************
* May 2018 - Simon Kaiser, University of Bern
********************************************************************************
program define oesch
version 7
syntax newvarname, oesch(varname numeric) [eight five replace]
tempvar originType
qui levelsof `oesch'
if "`r(levels)'" != "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16" {
display as error "Error: The input variable is not coded correctly. Levels are not 1-16."
exit 110
}
if "`eight'"=="eight" | "`five'"!="five" {
capture confirm variable oesch8_`varlist'
if !_rc & "`replace'"!="replace" {
display as error "Error: One or multiple of the variables to be generated already exist. Specify option 'replace' to overwrite them."
exit 110
}
}
if "`five'"=="five"{
capture confirm variable oesch5_`varlist'
if !_rc & "`replace'"!="replace" {
display as error "Error: One or multiple of the variables to be generated already exist. Specify option 'replace' to overwrite them."
exit 110
}
}
tempvar originVar
qui gen `originVar' = `oesch'
if "`eight'"=="eight" | "`five'"!="five"{
capture confirm variable oesch8_`varlist'
if !_rc & "`replace'"=="replace" {
drop oesch8_`varlist'
}
qui recode `originVar' (1 2=1)(3 4=2)(5 6=3)(7 8=4)(9 10=5)(11 12=6)(13 14=7)(15 16=8), gen(oesch8_`varlist')
display as text "Created 8-class variable:"
ds oesch8_`varlist'
label variable oesch8_`varlist' "`varlist' Oesch class position - 8 classes"
label define oesch8_`varlist' ///
1 "Self-employed professionals and large employers" ///
2 "Small business owners" ///
3 "Technical (semi-)professionals" ///
4 "Production workers" ///
5 "(Associate) managers" ///
6 "Clerks" ///
7 "Socio-cultural (semi-)professionals" ///
8 "Service workers", replace
label value oesch8_`varlist' oesch8_`varlist'
tab oesch8_`varlist'
}
if "`five'"=="five"{
capture confirm variable oesch5_`varlist'
if !_rc & "`replace'"=="replace" {
drop oesch5_`varlist'
}
qui recode `originVar' (1 2 5 9 13=1)(6 10 14=2)(3 4=3)(7 11 15=4)(8 12 16=5), gen(oesch5_`varlist')
display as text "Created 5-class variable:"
ds oesch5_`varlist'
label variable oesch5_`varlist' "`varlist' Oesch class position - 5 classes"
label define oesch5_`varlist' ///
1 "Higher-grade service class" ///
2 "Lower-grade service class" ///
3 "Small business owners" ///
4 "Skilled workers" ///
5 "Unskilled workers", replace
label value oesch5_`varlist' oesch5_`varlist'
tab oesch5_`varlist'
}
end