-
Notifications
You must be signed in to change notification settings - Fork 25
/
combine
executable file
·121 lines (106 loc) · 2.77 KB
/
combine
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
#!/usr/bin/perl
open(IN, "units-by-year-sum");
while (<IN>) {
chomp;
($year, $built) = split(/ /);
$net{$year} = $built;
}
open(IN, "housing-inventory");
while (<IN>) {
chomp;
($year, $built, $demolished, $converted, $net, $price) = split(/ /);
# Scale 2BR median to overall median
if ($price ne "") {
$price = $price * 0.9498 - 28.38;
$price{$year} = $price;
}
$net{$year} = $net;
}
close(IN);
open(IN, "medians");
while (<IN>) {
chomp;
($year, $price, $count, $p95, $p05) = split(/ /);
$price{$year} = $price;
$p95{$year} = $p95;
$p05{$year} = $p05;
}
close(IN);
$total = 379597 + $net{2015} + $net{2016} + $net{2017};
for ($year = 2017; $year >= 1900; $year--) {
$total{$year} = $total;
$total -= $net{$year};
}
open(IN, "employment/employment");
while (<IN>) {
chomp;
($year, $employment, $payroll) = split(/ /);
$employment{$year} = $employment;
$payroll{$year} = $payroll;
}
close(IN);
open(IN, "employment/employment-sc");
while (<IN>) {
chomp;
($year, $employment, $payroll) = split(/ /);
$employment_sc{$year} = $employment;
$payroll_sc{$year} = $payroll;
}
close(IN);
open(IN, "cpi/cpi");
while (<IN>) {
chomp;
($year, $cpi) = split(/ /);
$cpi{$year} = $cpi / 100;
}
close(IN);
open(IN, "evictions");
while (<IN>) {
chomp;
($year, $evictions) = split(/ /);
$evictions{$year} = $evictions;
}
close(IN);
open(IN, "interest");
while (<IN>) {
chomp;
($year, $interest) = split(/ /);
$interest{$year} = $interest;
}
close(IN);
open(IN, "irs-migration");
while (<IN>) {
chomp;
($year, $year2, $inh, $in, $outh, $out) = split(/ /);
$mig_in{$year2} = $in;
$mig_out{$year2} = $out;
}
close(IN);
open(IN, "permits");
while (<IN>) {
chomp;
($year, $permits) = split(/ /);
$permits{$year} = $permits;
}
close(IN);
for ($year = 1906; $year <= 2017; $year++) {
if ($price{$year - 1} != 0 && $cpi{$year} != 0) {
$priced = ($price{$year} / $cpi{$year}) / ($price{$year - 1} / $cpi{$year - 1}) - 1;
} else {
$priced = "";
}
if ($employment{$year} != 0 && $employment{$year - 1} != 0 && $cpi{$year - 1} != 0) {
$employmentd = $employment{$year} / $employment{$year - 1} - 1;
$waged = ($payroll{$year} / $cpi{$year}) / ($payroll{$year - 1} / $cpi{$year - 1}) - 1;
$pcwd = ($payroll{$year} / $cpi{$year} / $employment{$year}) / ($payroll{$year - 1} / $employment{$year - 1} / $cpi{$year - 1}) - 1;
} else {
$employmentd = "";
$waged = "";
}
if ($total{$year - 1} != 0) {
$housed = $total{$year} / $total{$year - 1} - 1;
} else {
$housed = "";
}
print "$year, $price{$year}, $total{$year}, $net{$year}, $employment{$year}, $payroll{$year}, $cpi{$year}, $p95{$year}, $p05{$year}, $employment_sc{$year}, $payroll_sc{$year}, $priced, $employmentd, $waged, $housed, $pcwd, $evictions{$year}, $interest{$year}, $mig_in{$year}, $mig_out{$year}, $permits{$year}\n";
}