-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
146 lines (123 loc) · 5.22 KB
/
Makefile
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
#
# (c) Daniel Green and Erik Loualiche
#
# Replication code for _State and Local Government Employment in the COVID-19 Crisis_
# Journal of Public Economics
#
# This file builds the datasets and generate all tables in the paper
# See the readme for dependencies and architecture of the code
#
# --------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------
all: create_folders \
build_census_finance build_lau build_census_employment \
build_cps_full build_reg \
build_main_figs_tables build_appendix_tables \
build_paper
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------
# ---
download_data:
mkdir tmp
cd tmp; wget "https://dataverse.harvard.edu/api/access/dataset/:persistentId/?persistentId=doi:10.7910/DVN/F9TYAI"
cd tmp; mv "index.html?persistentId=doi:10.7910%2FDVN%2FF9TYAI" "dataverse.zip"
cd tmp; unzip dataverse.zip
cp -R -n tmp/data/* ./data
rm -rf tmp
$(TIME-END)
@echo
# ---
create_folders:
mkdir -p code/log
mkdir -p derived
mkdir -p output
mkdir -p output/appendix
mkdir -p output/figures
mkdir -p output/tables
cd code; R CMD BATCH --vanilla install_necessary_packages.R log/install_necessary_packages.log.R
$(TIME-END)
@echo
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------
# --- build the CoG Revenue/Expenditure finance files
build_census_finance:
mkdir -p code/log
cd code; R CMD BATCH --vanilla assemble_1.R log/assemble_1.log.R
$(TIME-END)
@echo
# --- local area employment statistics
build_lau:
cd code; R CMD BATCH --vanilla assemble_2.R log/assemble_2.log.R
$(TIME-END)
@echo
# --- build the CoG employment side
build_census_employment:
cd code; R CMD BATCH --vanilla assemble_3.R log/assemble_3.log.R
$(TIME-END)
@echo
# --- read the CPS
build_cps_full:
cd code; $(STATA_CLI) -b do assemble_4.do
mv code/assemble_4.log code/log/assemble_4.log.do
$(TIME-END)
@echo
# --- create the regression datasets before we generate tables
build_reg:
cd code; R CMD BATCH --vanilla assemble_5.R log/assemble_5.log.R
$(TIME-END)
@echo
# --- generate summary statistics table
build_main_figs_tables:
cd code; R CMD BATCH --vanilla create_table_1.R log/create_table_1.log.R
cd code; $(STATA_CLI) -b do create_figs_tables.do
mv code/create_figs_tables.log code/log/create_figs_tables.log.do
$(TIME-END)
@echo
# --- generate Appendix tables
build_appendix_tables:
cd code; R CMD BATCH --vanilla create_appendix_table_1.R log/create_appendix_table_1.log.R
cd code; R CMD BATCH --vanilla create_appendix_table_2.R log/create_appendix_table_2.log.R
cd code; R CMD BATCH --vanilla create_appendix_table_3.R log/create_appendix_table_3.log.R
cd code; R CMD BATCH --vanilla create_appendix_table_8.R log/create_appendix_table_8.log.R
cd code; $(STATA_CLI) -b do create_appendix_figs_tables.do
mv code/create_appendix_figs_tables.log code/log/create_appendix_figs_tables.log.do
$(TIME-END)
@echo
# - build paper
build_paper:
cd manuscript; pdflatex -interaction=batchmode -output-directory ./ localgov_GL_jpube.tex
cd manuscript; bibtex localgov_GL_jpube
cd manuscript; pdflatex -interaction=batchmode -output-directory ./ localgov_GL_jpube.tex
cd manuscript; pdflatex -interaction=batchmode -output-directory ./ localgov_GL_jpube.tex
rm -f manuscript/*.aux manuscript/*.log manuscript/*.lot manuscript/*.out manuscript/*.toc manuscript/*.bbl manuscript/*.blg
mv manuscript/localgov_GL_jpube.pdf ./
$(TIME-END)
@echo
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------
# - generate figures for website
build_website_figures:
pdf2png -s @2x -i output/figures/cares_logpop_rf_no_controls.pdf -o output/figures/cares_logpop_rf_no_controls
pdf2png -s @8x -i output/figures/cares_logpop_rf_no_controls.pdf -o output/figures/cares_logpop_rf_no_controls
mv output/figures/[email protected] output/figures/cares_logpop_rf_no_controls.png
cp output/figures/cares_logpop_rf_no_controls.png docs/figures/
# - clean
clean.all:
rm -f output/tables/*.tex
rm -f output/figures/*.pdf
rm -f output/appendix/tables/*.tex
rm -f output/appendix/figures/*.pdf
rm -f code/log/**
rm -f derived/**
rm -rf data
# ------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------
# SHELL := /bin/bash
STATA_CLI := $(shell which stata-mp) # make sure that stata is in your path!
TIME_START := $(shell date +%s)
WHITE='\033[1;37m'
NC ='\033[0m' # No Color
define TIME-END
@time_end=`date +%s` ; time_exec=`awk -v "TS=${TIME_START}" -v "TE=$$time_end" 'BEGIN{TD=TE-TS;printf "%02dm:%02ds\n", TD/(60),TD%60}'` ; echo \\t${WHITE}cumulative time elapsed ... $${time_exec} ... $@ ${NC}
endef
# ------------------------------------------------------------------------------------------