All commands
# |
content
|
|
|
4 [+]
|
use
census2
, clear
All properties
key |
content |
command |
use |
indent |
0 |
options |
clear |
parameters |
census2 |
|
5 [+]
|
keep
if region < 3
All properties
key |
content |
command |
keep |
comment |
// =="N Cntrl" | region == "NE" |
if |
region < 3 |
indent |
0 |
parameters |
|
|
6 [+]
|
foreach
v of varlist pop* marriage divorce {
|
7 [+]
|
replace
`v' = `v'/1000
All properties
key |
content |
command |
replace |
indent |
1 |
parameters |
`v' = `v'/1000 |
|
8 [+]
|
format
`v' %8.1f
All properties
key |
content |
command |
format |
indent |
1 |
parameters |
`v' %8.1f |
|
9 [+]
|
}
All properties
key |
content |
command |
} |
indent |
0 |
parameters |
|
|
10 [+]
|
rename
popurban popurb
All properties
key |
content |
command |
rename |
indent |
0 |
parameters |
popurban popurb |
|
11 [+]
|
rename
marriage marr
All properties
key |
content |
command |
rename |
indent |
0 |
parameters |
marriage marr |
|
12 [+]
|
rename
divorce divr
All properties
key |
content |
command |
rename |
indent |
0 |
parameters |
divorce divr |
|
|
|
16 [+]
|
label
var state "State"
All properties
key |
content |
command |
label |
indent |
0 |
parameters |
var state "State" |
|
17 [+]
|
label
var pop "1980 Population, '000"
All properties
key |
content |
command |
label |
indent |
0 |
parameters |
var pop "1980 Population, '000" |
|
18 [+]
|
label
var popurb "1980 Urban population, '000"
|
19 [+]
|
label
var medage "Median age, years"
|
20 [+]
|
label
var drate "Death rate per 10,000"
|
21 [+]
|
label
var marr "Marriages, '000"
All properties
key |
content |
command |
label |
indent |
0 |
parameters |
var marr "Marriages, '000" |
|
22 [+]
|
label
var divr "Divorces, '000"
All properties
key |
content |
command |
label |
indent |
0 |
parameters |
var divr "Divorces, '000" |
|
|
|
24 [+]
|
label
data "1980 Census data for NE and NC states"
|
25 [+]
|
compress
All properties
key |
content |
command |
compress |
indent |
0 |
parameters |
|
|
26 [+]
|
keep
state region pop popurb medage marr divr
|
27 [+]
|
list
, sep(0)
All properties
key |
content |
command |
list |
indent |
0 |
options |
sep(0) |
parameters |
|
|
28 [+]
|
save
census2c
, replace
All properties
key |
content |
command |
save |
indent |
0 |
options |
replace |
parameters |
census2c |
|
29 [+]
|
outsheet
using census2c
, replace
All properties
key |
content |
command |
outsheet |
indent |
0 |
options |
replace |
parameters |
|
using |
census2c |
|
31 [+]
|
use
census2c
All properties
key |
content |
command |
use |
indent |
0 |
parameters |
census2c |
|
32 [+]
|
list
, sep(0)
All properties
key |
content |
command |
list |
indent |
0 |
options |
sep(0) |
parameters |
|
|
34 [+]
|
describe
All properties
key |
content |
command |
describe |
indent |
0 |
parameters |
|
|
36 [+]
|
generate
urbanized = popurb / pop
|
37 [+]
|
summarize
urbanized
All properties
key |
content |
command |
summarize |
indent |
0 |
parameters |
urbanized |
|
39 [+]
|
replace
urbanized = 100 * urbanized
All properties
key |
content |
command |
replace |
indent |
0 |
parameters |
urbanized = 100 * urbanized |
|
40 [+]
|
summarize
urbanized
All properties
key |
content |
command |
summarize |
indent |
0 |
parameters |
urbanized |
|
42 [+]
|
gsort
region -pop
All properties
key |
content |
command |
gsort |
indent |
0 |
parameters |
region -pop |
|
43 [+]
|
list
region state pop
, sepby(region)
|
45 [+]
|
sort
pop
All properties
key |
content |
command |
sort |
indent |
0 |
parameters |
pop |
|
46 [+]
|
list
state region pop
in 1/5
All properties
key |
content |
command |
list |
in |
1/5 |
indent |
0 |
parameters |
state region pop |
|
47 [+]
|
list
state region pop
in -5/l
All properties
key |
content |
command |
list |
in |
-5/l |
indent |
0 |
parameters |
state region pop |
|
49 [+]
|
gsort
-pop
All properties
key |
content |
command |
gsort |
indent |
0 |
parameters |
-pop |
|
50 [+]
|
list
state region pop
in 1/5
All properties
key |
content |
command |
list |
in |
1/5 |
indent |
0 |
parameters |
state region pop |
|
52 [+]
|
generate
medagel = medage
if pop > 5000
All properties
key |
content |
command |
generate |
if |
pop > 5000 |
indent |
0 |
parameters |
medagel = medage |
|
53 [+]
|
sort
state
All properties
key |
content |
command |
sort |
indent |
0 |
parameters |
state |
|
54 [+]
|
list
state region pop medagel
, sep(0)
|
56 [+]
|
summarize
medagel
All properties
key |
content |
command |
summarize |
indent |
0 |
parameters |
medagel |
|
57 [+]
|
summarize
medage
if pop > 5000
All properties
key |
content |
command |
summarize |
if |
pop > 5000 |
indent |
0 |
parameters |
medage |
|
59 [+]
|
generate
smallpop = 0
All properties
key |
content |
command |
generate |
indent |
0 |
parameters |
smallpop = 0 |
|
60 [+]
|
replace
smallpop = 1
if pop <= 5000 & !missing(pop)
|
61 [+]
|
generate
largepop = 0
All properties
key |
content |
command |
generate |
indent |
0 |
parameters |
largepop = 0 |
|
62 [+]
|
replace
largepop = 1
if pop > 5000 & !missing(pop)
|
63 [+]
|
list
state pop smallpop largepop
, sep(0)
|
65 [+]
|
drop
smallpop largepop
|
67 [+]
|
generate
smallpop = (pop <= 5000)
All properties
key |
content |
command |
generate |
indent |
0 |
parameters |
smallpop = (pop <= 5000) |
|
68 [+]
|
generate
largepop = (pop > 5000)
All properties
key |
content |
command |
generate |
indent |
0 |
parameters |
largepop = (pop > 5000) |
|
70 [+]
|
drop
smallpop largepop
|
71 [+]
|
generate
smallpop = (pop <= 5000)
if !missing(pop)
|
72 [+]
|
generate
largepop = (pop > 5000)
if !missing(pop)
|
|
|
76 [+]
|
summarize
medage marr divr
if region==1
|
77 [+]
|
summarize
medage marr divr
if region==2
|
79 [+]
|
sort
region
All properties
key |
content |
command |
sort |
indent |
0 |
parameters |
region |
|
80 [+]
|
by region:
summarize
medage marr divr
|
82 [+]
|
tabstat
medage
, by(region) statistics(N mean sd min max)
|
84 [+]
|
generate
popsize = smallpop + 2*largepop
|
85 [+]
|
bysort region popsize:
summarize
medage marr divr
|
87 [+]
|
describe
region
All properties
key |
content |
command |
describe |
indent |
0 |
parameters |
region |
|
89 [+]
|
label
list cenreg
All properties
key |
content |
command |
label |
indent |
0 |
parameters |
list cenreg |
|
91 [+]
|
label
variable urbanized "Population in urban areas, %"
|
92 [+]
|
label
variable smallpop "States with <= 5 million pop, 1980"
|
93 [+]
|
label
variable largepop "States with > 5 million pop, 1980"
|
94 [+]
|
label
variable popsize "Population size code"
|
95 [+]
|
describe
pop smallpop largepop popsize urbanized
|
97 [+]
|
label
define popsize 1 "<= 5 million" 2 "> 5 million"
|
98 [+]
|
label
values popsize popsize
|
99 [+]
|
describe
popsize
All properties
key |
content |
command |
describe |
indent |
0 |
parameters |
popsize |
|
100 [+]
|
bysort popsize:
summarize
medage
|
102 [+]
|
label
data "1980 US Census data with population size indicators"
|
104 [+]
|
note:
Subset of Census data
, prepared on TS for Chapter 2
|
105 [+]
|
note
medagel: median age for large states only
|
106 [+]
|
note
popsize: variable separating states by population size
|
107 [+]
|
note
popsize: value label popsize defined for this variable
|
108 [+]
|
describe
All properties
key |
content |
command |
describe |
indent |
0 |
parameters |
|
|
109 [+]
|
notes
All properties
key |
content |
command |
notes |
indent |
0 |
parameters |
|
|
114 [+]
|
generate
netmarr2x = cond(marr/divr > 2.0, 1, 2)
|
115 [+]
|
label
define netmarr2xc 1 "marr > 2 divr" 2 "marr <= 2 divr"
|
116 [+]
|
label
values netmarr2x netmarr2xc
|
117 [+]
|
tabstat
pop medage
, by(netmarr2x)
|
119 [+]
|
generate
medagebrack = recode(medage, 28, 29, 30, 31, 32, 33)
-
generate medagebrack = recode(medage, 28, 29, 30, 31, 32, 33)
|
120 [+]
|
tabulate
medagebrack
All properties
key |
content |
command |
tabulate |
indent |
0 |
parameters |
medagebrack |
|
122 [+]
|
histogram
medagebrack
, discrete frequency ///
lcolor(black) fcolor(gs15) addlabels ///
addlabopts(mlabposition(6)) xtitle(Upper limits of median age)
|
127 [+]
|
gsort
region -pop
All properties
key |
content |
command |
gsort |
indent |
0 |
parameters |
region -pop |
|
128 [+]
|
by region:
generate
totpop = sum(pop)
|
129 [+]
|
list
region state pop totpop
, sepby(region)
|
131 [+]
|
by region:
list
region totpop
if _n == _N
|
133 [+]
|
by region:
egen
meanpop = mean(pop)
|
134 [+]
|
list
region state pop meanpop
, sepby(region)
|
136 [+]
|
generate
popsize = smallpop + 2*largepop
|
137 [+]
|
label
variable popsize "Population size code"
|
138 [+]
|
label
define popsize 1 "<= 5 million" 2 "> 5 million"
, modify
|
139 [+]
|
label
values popsize popsize
|
140 [+]
|
bysort region popsize:
egen
meanpop2 = mean(pop)
|
141 [+]
|
list
region popsize state pop meanpop2
, sepby(region popsize)
|
143 [+]
|
use
gdp4cty
, clear
All properties
key |
content |
command |
use |
indent |
0 |
options |
clear |
parameters |
gdp4cty |
|
144 [+]
|
local
country US UK DE FR
All properties
key |
content |
command |
local |
indent |
0 |
parameters |
country US UK DE FR |
|
145 [+]
|
local
cc 1
All properties
key |
content |
command |
local |
indent |
0 |
parameters |
cc 1 |
|
146 [+]
|
foreach
c of local country {
All properties
key |
content |
command |
foreach |
indent |
0 |
parameters |
c of local country { |
|
147 [+]
|
generate
double `c'gdp = gdp`cc'
|
148 [+]
|
local
++cc
All properties
key |
content |
command |
local |
indent |
1 |
parameters |
++cc |
|
149 [+]
|
}
All properties
key |
content |
command |
} |
indent |
0 |
parameters |
|
|
150 [+]
|
foreach
c
in US UK DE FR {
All properties
key |
content |
command |
foreach |
in |
US UK DE FR { |
indent |
0 |
parameters |
c |
|
151 [+]
|
generate
double lngdp`c' = log(`c'gdp)
|
152 [+]
|
summarize
lngdp`c'
All properties
key |
content |
command |
summarize |
indent |
1 |
parameters |
lngdp`c' |
|
153 [+]
|
}
All properties
key |
content |
command |
} |
indent |
0 |
parameters |
|
|
155 [+]
|
use
census2c
, clear
All properties
key |
content |
command |
use |
indent |
0 |
options |
clear |
parameters |
census2c |
|
156 [+]
|
summarize
pop
All properties
key |
content |
command |
summarize |
indent |
0 |
parameters |
pop |
|
157 [+]
|
return
list
All properties
key |
content |
command |
return |
indent |
0 |
parameters |
list |
|
159 [+]
|
mean
pop popurb
All properties
key |
content |
command |
mean |
indent |
0 |
parameters |
pop popurb |
|
160 [+]
|
ereturn
list
All properties
key |
content |
command |
ereturn |
indent |
0 |
parameters |
list |
|
161 [+]
|
matrix
list e(b)
All properties
key |
content |
command |
matrix |
indent |
0 |
parameters |
list e(b) |
|
162 [+]
|
matrix
list e(V)
All properties
key |
content |
command |
matrix |
indent |
0 |
parameters |
list e(V) |
|