-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.do
152 lines (114 loc) · 4.23 KB
/
main.do
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
* Analyze the shape of ability-earnings relation
/* Finnish half of data analysis for Bratsberg-Rogeberg-Terviö (2023)
"Steeper at the top: cognitive ability and earnings in Finland and Norway"
Assumes *.do files in present working directory
Paths at TK (Tilastokeskus = "Statistics Finland" aka StatFin) remote servers
This (final !) version 2024-03-06
`c(username)' MarTervio-a72
*/
* Global PATHS
* ============
* BEGIN Repository version only:
* Hardcode global paths from user profile; values as of 2024-03-06
global TKDATA "D:/ready-made"
global CUSTDATA "D:/a72/custom-made"
global WORK "W:/marko"
global OUT "O:/marko"
* END Repository version-only
* INPUT:
macro list TKDATA CUSTDATA // read-only drives at TK
global TULODATA "$TKDATA/CONTINUOUS/FOLK_TULO_C" // TK income module
* OUTPUT:
macro list WORK // writable drive for intermediate files at TK, from user profile
macro list OUT // output drive for taking files out of TK, from user profile
global AUX "W:/auxiliary" // preprocessed data, shared between papers
global TEMP "$WORK/steeper" // temporary files
global GPH "$TEMP/gph" // Stata graphs to combine
global outDir "$OUT/takeout" // Output
cap mkdir "$outDir"
cap mkdir "$outDir/tables"
cap mkdir "$outDir/figures"
cap mkdir "$outDir/code"
cap mkdir "$TEMP"
cap mkdir "$GPH"
* Deflator settings
* -----------------
global cpiBaseYear = 2020
global Deflator "$AUX/cpi_deflator.dta"
confirm file "$Deflator" // dta extracted from StatFin metadata by cpi_deflator.do
* Helpers
* -------
confirm file int_destring.do // speed up destring
confirm file fdf_labels.do // for cleaning and labeling variables in FDF data
*confirm file cpi_deflator.do // update dta-format deflator
* Preprocess
* ==========
* Statistics Finland registry data
* --------------------------------
do preprocess_FOLK
desc using "$AUX/person_static"
desc using "$AUX/folk_years"
do preprocess_TULO
desc using "$AUX/earn_years"
* Military test score data
* ------------------------
do preprocess_FDF
desc using "$AUX/pkoe"
* Gather data for "Steeper at the top"
* ====================================
* From panel to static variables
* ------------------------------
do collapse_males
desc using "$TEMP/male_static"
* Anchored test scores
* --------------------
do dimreduce_FDF
desc using "$TEMP/skill_measures"
* Analysis data
* ==============
do define_subsets
desc using "$TEMP/subsets"
do analysis_samples
ls "$TEMP/sample_*"
desc using "$TEMP/sample_full"
desc using "$TEMP/sample_intermediate"
desc using "$TEMP/sample_restricted"
* Summarize data
* ==============
do summary_stats
ls "$outDir/tables/*.xlsx"
* ==============================================
* Takeout tables - all graphs are based on these
* ==============================================
* Prepare dta's for graphs with earnings on horizontal axis
do stats_vs_earn
desc using "$outDir/tables/cog_vs_earnings"
desc using "$outDir/tables/stanshares_vs_earnings"
desc using "$outDir/tables/cog-sd_vs_earn"
desc using "$outDir/tables/subscores_vs_earnings"
desc using "$outDir/tables/altscores_vs_earnings"
* Prepare dta's for graphs with FDF test results on horizontal axis
do stats_vs_cog
desc using "$outDir/tables/earn_vs_cog"
desc using "$outDir/tables/earn_vs_cog-percentiles"
* Prepare the dta for comparisons with Keuschnigg et al (2023)
do compare_variants
desc using "$outDir/tables/alt_percentiles"
* ==========================
* Optional preview of graphs
* ==========================
do preview_graphs
ls "$outDir/figures/*.png"
* ==========================
* Copy codes to takeout dir
* ==========================
* code shared with other a72 projects
foreach fname in "preprocess_FOLK" "preprocess_TULO" "preprocess_FDF" "dimreduce_FDF" "fdf_labels" "int_destring" "cpi_deflator" {
copy "`fname'.do" "$outDir/code/`fname'.do", replace
}
* code specific to Bratsberg-Rogeberg-Terviö (2023)
foreach fname in "main" "collapse_males" "define_subsets" "analysis_samples" "summary_stats" "stats_vs_earn" "stats_vs_cog" "compare_variants" "preview_graphs" {
copy "`fname'.do" "$outDir/code/`fname'.do", replace
}
ls "$outDir/code/"
clear