Documente Academic
Documente Profesional
Documente Cultură
log using
set mem
doedit
cd
PU/DSS/OTR
Features
Stata
SPSS
SAS
Learning curve
Steep/gradual
Gradual/flat
Pretty steep
Pretty steep
User interface
Programming/point-and-click
Mostly point-and-click
Programming
Programming
Very strong
Moderate
Very strong
Very strong
Data analysis
Powerful
Powerful
Powerful/versatile
Powerful/versatile
Graphics
Very good
Very good
Good
Excellent
Affordable (perpetual
licenses, renew only when
upgrade)
Expensive (yearly
renewal)
Open source
(free)
Data manipulation
Cost
PU/DSS/OTR
To change the working directory to avoid typing the whole path when
calling or saving files, type:
cd c:\mydata
. cd c:\mydata
c:\mydata
Use quotes if the new directory has blank spaces, for example
cd h:\stata and data
. cd "h:\stata and data"
h:\stata and data
PU/DSS/OTR
Create a log file, sort of Statas built-in tape recorder and where you can:
1) retrieve the output of your work and 2) keep a record of your work.
In the command line type:
log using mylog.log
This will create the file mylog.log in your working directory. You can
read it using any word processor (notepad, word, etc.).
To close a log file type:
log close
To add more output to an existing log file add the option append, type:
log using mylog.log, append
To replace a log file add the option replace, type:
log using mylog.log, replace
Note that the option replace will delete the contents of the previous
version of the log.
PU/DSS/OTR
PU/DSS/OTR
lookfor
. lookfor educ
variable name
educ
storage display
type
format
byte
%10.0g
value
label
variable label
Education of R.
lookfor
PU/DSS/OTR
if
PU/DSS/OTR
PU/DSS/OTR
fduse
usespss
usesas
help usesas
PU/DSS/OTR
edit
click,
elecPaste.
NOTE
insheet
PU/DSS/OTR
.xl
x"
hee
( Shee
1") firstrow clear
describe
describe
. describe
Contains data from http://dss.princeton.edu/training/students.dta
obs:
30
vars:
14
29 Sep 2009 17:12
size:
2,580 (99.9% of memory free)
variable name
storage
type
id
lastname
firstname
city
state
gender
student status
major
country
age
sat
averagescoreg~e
heightin
newspaperread~k
byte
str5
str6
str14
str14
str6
str13
str8
str9
byte
int
byte
byte
byte
display
format
%8.0g
%9s
%9s
%14s
%14s
%9s
%13s
%9s
%9s
%8.0g
%8.0g
%8.0g
%8.0g
%8.0g
value
label
variable label
ID
Last Name
First Name
City
State
Gender
Student Status
Major
Country
Age
SAT
Average score (grade)
Height (in)
Newspaper readership
summarize
summarize
. summarize
Variable
Obs
Mean
Std. Dev.
Min
Max
id
lastname
firstname
city
state
30
0
0
0
0
15.5
8.803408
30
gender
studentsta~s
major
country
age
0
0
0
0
30
25.2
6.870226
18
39
sat
averagesco~e
heightin
newspaperr~k
30
30
30
30
1848.9
80.36667
66.43333
4.866667
275.1122
10.11139
4.658573
1.279368
1338
63
59
3
2309
96
75
7
tab varname.
. tab major
Major
Freq.
Percent
Cum.
Econ
Math
Politics
10
10
10
33.33
33.33
33.33
33.33
66.67
100.00
Total
30
100.00
. tab readnews
Newspaper
readership
(times/wk)
Freq.
Percent
Cum.
3
4
5
6
7
6
5
9
7
3
20.00
16.67
30.00
23.33
10.00
20.00
36.67
66.67
90.00
100.00
Total
30
100.00
table
Command table produces frequencies and descriptive statistics per category. For more info and a list of
all statistics type help table. Here are some examples, type
table gender, contents(freq mean age mean score)
Freq.
mean(age)
mean(score)
Female
Male
15
15
23.2
27.2
78.73333
82
The mean age of females is 23 years, for males is 27. The mean score is 78 for females and 82 for
males. Here is another example:
table major, contents(freq mean age mean sat mean score mean readnews)
. table major, contents(freq mean
score mean
readnews)
Major
Freq.
mean(age)
mean(sat)
mean(score)
mean(read~s)
Econ
Math
Politics
10
10
10
23.8
23
28.8
1806
1844
1896.7
76.2
79.8
85.1
4.4
5.3
4.9
PU/DSS/OTR
frequency
row percentage
column percentage
Status of
Nat'l Eco
Gender of Respondent
Male
Female
Total
Very well
90
60.40
14.33
59
39.60
7.92
149
100.00
10.85
Fairly well
337
50.30
53.66
333
49.70
44.70
670
100.00
48.80
Fairly badly
139
39.94
22.13
209
60.06
28.05
348
100.00
25.35
Very badly
57
29.84
9.08
134
70.16
17.99
191
100.00
13.91
Not sure
2
16.67
0.32
10
83.33
1.34
12
100.00
0.87
Refused
3
100.00
0.48
0
0.00
0.00
3
100.00
0.22
Total
628
45.74
100.00
745
54.26
100.00
1,373
100.00
100.00
tab1
tab2
PU/DSS/OTR
frequency
row percentage
column percentage
Status of
Nat'l Eco
Gender of Respondent
Male
Female
Total
Very well
90
60.40
14.33
59
39.60
7.92
149
100.00
10.85
Fairly well
337
50.30
53.66
333
49.70
44.70
670
100.00
48.80
Fairly badly
139
39.94
22.13
209
60.06
28.05
348
100.00
25.35
Very badly
57
29.84
9.08
134
70.16
17.99
191
100.00
13.91
2
16.67
0.32
10
83.33
1.34
12
100.00
0.87
3
100.00
0.48
0
0.00
0.00
628
45.74
100.00
745
54.26
100.00
Not sure
Refused
Total
RECODE of
ecostatu
(Status of
Nat'l Eco)
Gender of Respondent
Male
Female
Total
Well
3
100.00
0.22
427
52.14
67.99
392
47.86
52.62
819
100.00
59.65
Bad
1,373
100.00
100.00
196
36.36
31.21
343
63.64
46.04
539
100.00
39.26
Not sure/ref
5
33.33
0.80
10
66.67
1.34
15
100.00
1.09
Total
628
45.74
100.00
745
54.26
100.00
1,373
100.00
100.00
tab ecostatu1 gender, column row nokey chi2 lrchi2 V exact gamma taub
. tab ecostatu1 gender, column row nokey chi2 lrchi2 V exact gamma taub
Enumerating sample-space
stage 3: enumerations =
stage 2: enumerations =
stage 1: enumerations =
RECODE of
ecostatu
(Status of
Nat'l Eco)
combinations:
1
16
0
Gender of Respondent
Male
Female
427
52.14
67.99
392
47.86
52.62
819
100.00
59.65
Bad
196
36.36
31.21
343
63.64
46.04
539
100.00
39.26
Not sure/ref
5
33.33
0.80
10
66.67
1.34
15
100.00
1.09
Total
628
45.74
100.00
745
54.26
100.00
1,373
100.00
100.00
33.5266
33.8162
0.1563
0.3095
0.1553
Pr = 0.000
Pr = 0.000
=
=
=
=
=
=
exact
chi2
Total
Well
Pearson chi2(2)
likelihood-ratio chi2(2)
Cramr's V
gamma
Kendall's tau-b
Fisher's exact
lrchi2
ASE = 0.050
ASE = 0.026
0.000
PU/DSS/OTR
tabstat
tabstat age sat score heightin readnews, s(mean median sd var count range min max)
. tabstat
age sat score heightin readnews, s(mean median sd var count range min max)
stats
age
sat
score
heightin
readnews
mean
p50
sd
variance
N
range
min
max
25.2
23
6.870226
47.2
30
21
18
39
1848.9
1817
275.1122
75686.71
30
971
1338
2309
80.36667
79.5
10.11139
102.2402
30
33
63
96
66.43333
66.5
4.658573
21.7023
30
16
59
75
4.866667
5
1.279368
1.636782
30
4
3
7
PU/DSS/OTR
tabstat age sat score heightin readnews, s(mean median sd var count range min max) by(gender)
. tabstat
age sat score heightin readnews, s(mean median sd var count range min max) by(gender)
age
sat
score
heightin
readnews
Female
23.2
20
6.581359
43.31429
15
20
18
38
1871.8
1821
307.587
94609.74
15
971
1338
2309
78.73333
79
10.66012
113.6381
15
32
63
95
63.4
63
3.112188
9.685714
15
9
59
68
5.2
5
1.207122
1.457143
15
4
3
7
Male
27.2
28
6.773899
45.88571
15
21
18
39
1826
1787
247.0752
61046.14
15
845
1434
2279
82
82
9.613978
92.42857
15
31
65
96
69.46667
71
3.943651
15.55238
15
12
63
75
4.533333
4
1.302013
1.695238
15
4
3
7
Total
25.2
23
6.870226
47.2
30
21
18
39
1848.9
1817
275.1122
75686.71
30
971
1338
2309
80.36667
79.5
10.11139
102.2402
30
33
63
96
66.43333
66.5
4.658573
21.7023
30
16
59
75
4.866667
5
1.279368
1.636782
30
4
3
7
help tabstat
PU/DSS/OTR
. tab gender
Key
Gender
Freq.
Percent
Female
Male
15
15
50.00
50.00
Total
30
100.00
Cum.
frequency
row percentage
column percentage
50.00
100.00
Gender
Student Status
Graduate Undergrad
Total
Female
5
33.33
33.33
10
66.67
66.67
15
100.00
50.00
Male
10
66.67
66.67
5
33.33
33.33
15
100.00
50.00
Total
15
50.00
100.00
15
50.00
100.00
30
100.00
100.00
Econ
Major
Math
Politics
Total
Female
1952.3333
312.43773
3
1762.5
317.99326
8
2030
262.25052
4
1871.8
307.58697
15
Male
1743.2857
155.6146
7
2170
72.124892
2
1807.8333
288.99994
6
1826
247.07518
15
Total
1806
219.16559
10
1844
329.76928
10
1896.7
287.20687
10
1848.9
275.11218
30
PU/DSS/OTR
. bysort
frequency
row percentage
column percentage
Major
Math
Gender
Econ
Politics
Total
Female
0
0.00
0.00
2
40.00
66.67
3
60.00
37.50
5
100.00
33.33
Male
4
40.00
100.00
1
10.00
33.33
5
50.00
62.50
10
100.00
66.67
Total
4
26.67
100.00
3
20.00
100.00
8
53.33
100.00
15
100.00
100.00
frequency
row percentage
column percentage
Major
Math
Gender
Econ
Politics
Total
Female
3
30.00
50.00
6
60.00
85.71
1
10.00
50.00
10
100.00
66.67
Male
3
60.00
50.00
1
20.00
14.29
1
20.00
50.00
5
100.00
33.33
Total
6
40.00
100.00
7
46.67
100.00
2
13.33
100.00
15
100.00
100.00
PU/DSS/OTR
. bysort
Econ
Major
Math
Politics
Total
Female
.
.
0
1777
373.35238
2
2092.6667
282.13531
3
1966.4
323.32924
5
Male
1659.25
154.66819
4
2221
0
1
1785.6
317.32286
5
1778.6
284.3086
10
Total
1659.25
154.66819
4
1925
367.97826
3
1900.75
324.8669
8
1841.2
300.38219
15
Econ
Major
Math
Politics
Total
Female
1952.3333
312.43773
3
1757.6667
337.01197
6
1842
0
1
1824.5
305.36872
10
Male
1855.3333
61.711695
3
2119
0
1
1919
0
1
1920.8
122.23011
5
Total
1903.8333
208.30979
6
1809.2857
336.59952
7
1880.5
54.447222
2
1856.6
257.72682
15
PU/DSS/OTR
Before
After
var1
var2
var3
var4
var5
id
country
party
imports
exports
After
label
label
label
label
label
variable
variable
variable
variable
variable
id "Unique identifier"
country "Country name"
party "Political party in power"
imports "Imports as % of GDP"
exports "Exports as % of GDP"
PU/DSS/OTR
Setp 2: Assign that label to a variable with those categories using label values:
label values var1 label1
If another variable has the same corresponding categories you can use the same
label, type
label values var2 label1
To generate a new variable use the command generate (gen for short),
generate [newvar] = [expression]
results for the first five students
generate score2 = score/100
generate readnews2 = readnews*4
You can also use generate with string variables. For example:
results for the first five students
generate fullname = last + , + first
label variable fullname Student full name
browse id fullname last first
PU/DSS/OTR
Freq.
Percent
Cum.
0
1
25
5
83.33
16.67
83.33
100.00
Total
30
100.00
fem_less25
fem_less25
Freq.
Percent
Cum.
0
1
19
11
63.33
36.67
63.33
100.00
Total
30
100.00
. tab
age gender
Student Status
Graduate Undergrad
Age
Gender
Female
Male
Total
Total
Female
Male
5
10
10
5
15
15
Total
15
15
30
18
19
20
21
25
26
28
30
31
33
37
38
39
4
3
1
2
1
0
0
1
1
1
0
1
0
1
2
1
1
1
1
1
3
0
2
1
0
1
5
5
2
3
2
1
1
4
1
3
1
1
1
Total
15
15
30
PU/DSS/OTR
Age
Freq.
Percent
Cum.
18
19
20
21
25
26
28
30
31
33
37
38
39
5
5
2
3
2
1
1
4
1
3
1
1
1
16.67
16.67
6.67
10.00
6.67
3.33
3.33
13.33
3.33
10.00
3.33
3.33
3.33
16.67
33.33
40.00
50.00
56.67
60.00
63.33
76.67
80.00
90.00
93.33
96.67
100.00
Total
30
100.00
, type
Type help recode for more details
Freq.
Percent
Cum.
18 to 19
20 to 29
30 to 39
10
9
11
33.33
30.00
36.67
33.33
63.33
100.00
Total
30
100.00
PU/DSS/OTR
egen
You can recode variables using the command egen
cut/group.
Freq.
Percent
18
20
30
10
9
11
33.33
30.00
36.67
Total
30
100.00
Cum.
33.33
63.33
100.00
group,
egen newvariable = cut (oldvariable), group(# of groups)
. egen agegroups3=cut(age), group(3)
. tab agegroups3
agegroups3
Freq.
Percent
0
1
2
10
9
11
33.33
30.00
36.67
Total
30
100.00
Cum.
33.33
63.33
100.00
After
. tab read, missing
. tab read
Newspaper
readership
(times/wk)
Freq.
Percent
Cum.
3
4
5
6
7
6
5
9
7
3
20.00
16.67
30.00
23.33
10.00
20.00
36.67
66.67
90.00
100.00
Total
30
100.00
Newspaper
readership
(times/wk)
Freq.
Percent
Cum.
3
4
5
.
6
5
9
10
20.00
16.67
30.00
33.33
20.00
36.67
66.67
100.00
Total
30
100.00
Before
After
. tab read
Newspaper
readership
(times/wk)
Freq.
Percent
Cum.
3
4
5
6
7
6
5
9
7
3
20.00
16.67
30.00
23.33
10.00
20.00
36.67
66.67
90.00
100.00
Total
30
100.00
Newspaper
readership
(times/wk)
Freq.
Percent
Cum.
3
4
5
6
.
6
5
9
7
3
20.00
16.67
30.00
23.33
10.00
20.00
36.67
66.67
90.00
100.00
Total
30
100.00
Before
After
. tab gender
. tab gender
Gender
Freq.
Percent
Cum.
Gender
Freq.
Percent
Cum.
Female
Male
15
15
50.00
50.00
50.00
100.00
F
M
15
15
50.00
50.00
50.00
100.00
Total
30
100.00
Total
30
100.00
var2
1.
2.
3.
4.
5.
123A33
2144F
2312A
3567754G
35457S
12333
2144
2312
3567754
35457
6.
7.
8.
9.
10.
34234N
234212*
23146}
31231)
AFN.345
34234
234212
23146
31231
345
11.
NYSE.12
12
1.
2.
3.
4.
5.
var1
var2
AFM.123
ADGT.2345
ACDET.1234564
CDFGEEGY.596544
ACGETYF.1235
AFM
ADGT
ACDET
CDFGEEGY
ACGETYF
Using _n, you can create a unique identifier for each case in your data, type
Check the results in the data editor, idall is equal to id
Using _N you can also create a variable with the total number of cases in your
dataset:
Check the results in the data editor:
PU/DSS/OTR
PU/DSS/OTR
tsset year
time variable:
delta:
gen l1_year=L1.year
gen l2_year=L2.year
gen f1_year=F1.year
gen f2_year=F2.year
NOTE: Notice the square brackets
For times series see: http://dss.princeton.edu/training/TS101.pdf
PU/DSS/OTR
You can create a variable based on one value of another variable. For example,
create a variable with the highest SAT value in the sample.
Check the results in the data editor:
NOTE: You could get the same result without sorting by using
egen and the max function
PU/DSS/OTR
Before
After
sort var1 var2
gsort is another command to sort data. The difference between gsort and
sort is that with gsort you can sort in ascending or descending order, while
with sort you can sort only in ascending order. Use +/- to indicate whether you
want to sort in ascending/descending order. Here are some examples:
PU/DSS/OTR
After
Or
PU/DSS/OTR
You can drop cases selectively using the conditional if, for example
drop if var1==1
PU/DSS/OTR
PU/DSS/OTR
RECLINK - Matching fuzzy text. Reclink stands for record linkage. It is a program written by Michael Blasnik to merge imperfect
string variables. For example
Reclink helps you to merge the two databases by using a matching algorithm for these types of variables. Since it is a user
created program, you may need to install it by typing ssc install reclink. Once installed you can type help reclink
for details
As in merge, the merging variables must have the same name: state, university, city, name, etc. Both the master and the using
files should have an id variable identifying each observation.
Note: the name of ids must be different, for example id1 (id master) and id2 (id using). Sort both files by the matching (merging)
variables. The basic sytax is:
reclink var1 var2 var3 using myusingdata, gen(myscore) idm(id1) idu(id2)
The variable myscore indicates the strength of the match; a perfect match will have a score of 1. Description (from reclink help
pages):
reclink uses record linkage methods to match observations between two datasets where no perfect key fields exist -essentially a fuzzy merge. reclink allows for user-defined matching and non-matching weights for each variable and
employs a bigram string comparator to assess imperfect string matches.
The master and using datasets must each have a variable that uniquely identifies observations. Two new variables are
created, one to hold the matching score (scaled 0-1) and one for the merge variable. In addition, all of the
matching variables from the using dataset are brought into the master dataset (with newly prefixed names) to allow
for manual review of matches.
PU/DSS/OTR
scatter
twoway
scatter y x
help scatter
twoway scatter sat age, mlabel(last)
2400
2400
2200
2200
SAT
1800
2000
SAT
1800
2000
DOE15
DOE11
DOE29
DOE01
DOE10
DOE16
DOE28
DOE05
DOE02
DOE24
DOE26
DOE30
DOE25
DOE03
DOE08
DOE04
DOE21
DOE19
DOE13
1600
1600
DOE12
DOE17
DOE14
DOE20
1400
1400
25
30
35
DOE27
DOE07
20
40
25
30
2400
DOE29
DOE01
DOE10
DOE15
2200
DOE16
2000
1800
DOE25
DOE03
DOE19
DOE13
DOE17
DOE18
DOE22
DOE06
DOE23
DOE09
DOE27
DOE07
25
30
Age
SAT
35
DOE05
DOE02
DOE24
DOE26
DOE30
1600
1800
1600
DOE24
DOE20
1400
DOE29
DOE01
DOE10
DOE16
DOE28
DOE05
DOE14
20
DOE11
DOE25
DOE03
DOE08
DOE04
DOE21
DOE12
40
DOE19
DOE13
DOE17
DOE14
DOE18
DOE22
DOE20
DOE06
DOE23
DOE09
1400
2000
DOE28
DOE02
DOE08
DOE04
DOE21
DOE12
40
2400
2200
DOE15
DOE11
DOE26
DOE30
35
Age
Age
DOE06
DOE23
DOE09
20
DOE18
DOE22
DOE27
DOE07
20
25
30
35
40
Age
Fitted values
SAT
Fitted values
PU/DSS/OTR
Econ
Math
DOE15
DOE30
DOE08 DOE25
DOE21
DOE12
DOE19
DOE17
DOE18
DOE27
DOE11
DOE28
DOE02
DOE04
DOE14
DOE09
DOE07
DOE16
DOE05
DOE06
Politics
Total
DOE29
DOE01
DOE10
DOE26
DOE03
DOE24
DOE13
DOE22
DOE23
20
25
30
35
DOE15
DOE11
DOE28
DOE02
DOE26
DOE30
DOE25
DOE03
DOE08
DOE04
DOE21
DOE12
DOE20 DOE14
DOE09
DOE07
40
20
DOE16
DOE29
DOE01
DOE10
DOE19
DOE13
25
DOE22
DOE23
DOE27
30
DOE05
DOE24
DOE17
35
DOE18
DOE20
DOE06
40
Age
SAT
Fitted values
Graphs by Major
help histogram
Frequency
Frequency
10
10
15
15
20
25
30
Age
35
40
20
25
30
35
40
Age
PU/DSS/OTR
catplot
To graph categorical data use catplot. Since it is a user defined program you have to
install it typing: ssc install catplot
Major
Math
Politics
Total
4
40.00
40.00
13.33
5
50.00
50.00
16.67
1
10.00
10.00
3.33
10
100.00
33.33
33.33
4
44.44
40.00
13.33
3
33.33
30.00
10.00
2
22.22
20.00
6.67
9
100.00
30.00
30.00
30 to 39
2
18.18
20.00
6.67
2
18.18
20.00
6.67
7
63.64
70.00
23.33
11
100.00
36.67
36.67
Total
10
33.33
100.00
33.33
10
33.33
100.00
33.33
10
33.33
100.00
33.33
30
100.00
100.00
100.00
18 to 19
20 to 29
frequency
4
Econ
RECODE of
age (Age)
frequency
row percentage
column percentage
cell percentage
18 to 19
20 to 29
30 to 39
catplot
blabel(bar)
63.6364
60
Row %
50
44.4444
percent of category
20
40
. tab
Key
frequency
row percentage
column percentage
40
33.3333
22.2222
18.1818 18.1818
10
RECODE of
age (Age)
18 to 19
Econ
Major
Math
Politics
Total
4
40.00
40.00
5
50.00
50.00
1
10.00
10.00
10
100.00
33.33
18 to 19
20 to 29
30 to 39
18 to 19
40
Econ 20 to 29
20 to 29
30 to 39
Total
4
44.44
40.00
3
33.33
30.00
2
22.22
20.00
9
100.00
30.00
30 to 39
Math 20 to 29
2
18.18
20.00
2
18.18
20.00
7
63.64
70.00
11
100.00
36.67
10
33.33
100.00
10
33.33
100.00
10
33.33
100.00
30
100.00
100.00
40
18 to 19
50
30
30 to 39
20
18 to 19
10
Politics 20 to 29
20
30 to 39
70
catplot
Column %
20
20
40
percent of category
60
80
blabel(bar)
PU/DSS/OTR
catplot
18 to 19
Male
Econ
Math
18 to 19
Politics
Math
Politics
Econ
Major
Math
Politics
Total
18 to 19
2
66.67
5
62.50
0
0.00
7
46.67
20 to 29
1
33.33
1
12.50
2
50.00
4
26.67
30 to 39
0
0.00
2
25.00
2
50.00
4
26.67
Total
3
100.00
8
100.00
4
100.00
15
100.00
20 to 29
Econ
Math
Econ
20 to 29
Politics
Politics
Econ
30 to 39
Math
Econ
Math
Politics
30 to 39
Math
Politics
frequency
Graphs by Gender
RECODE of
age (Age)
Econ
Major
Math
Politics
Total
18 to 19
2
28.57
0
0.00
1
16.67
3
20.00
20 to 29
3
42.86
2
100.00
0
0.00
5
33.33
18 to 19
62.5
0
0.00
5
83.33
7
46.67
Total
7
100.00
2
100.00
6
100.00
15
100.00
18 to 19
Politics
20 to 29
20 to 29
12.5
42.8571
Math
100
Politics
50
Econ
Math
30 to 39
25
Politics
catplot
gender)
16.6667
Econ
33.3333
Math
Econ
30 to 39
28.5714
Math
Politics
Politics
2
28.57
Econ
66.6667
Math
Econ
30 to 39
Male
20
40
60
Math
Politics
50
28.5714
80 100
83.3333
20
40
60
80 100
percent of category
Graphs by Gender
PU/DSS/OTR
Female, Math
19
Female, Politics
23
26.75
70.3333
79
Male, Econ
Male, Math
25.8571
Male, Politics
23
30.1667
78.7143
84.5
83
20
40
60
80
85.5
20
40
60
80
Total
25.2
80.3667
20
40
60
80
mean of age
mean of averagescoregrade
Student indicators
31.4
Female
80.2
5
Graduate
31.1
Male
81.1
4.9
19.1
Female
78
5.3
Undergraduate
19.4
Male
83.8
3.8
20
40
Age
Newsp read
60
80
Score
PU/DSS/OTR
You can create dummy variables by either using recode or using a combination of tab/gen commands:
tab major, generate(major_dum)
. tab major, generate(major_dum)
Major
Freq.
Percent
Cum.
Econ
Math
Politics
10
10
10
33.33
33.33
33.33
33.33
66.67
100.00
Total
30
100.00
. tab1
Freq.
Percent
Cum.
0
1
20
10
66.67
33.33
66.67
100.00
Total
30
100.00
Freq.
Percent
Cum.
0
1
20
10
66.67
33.33
66.67
100.00
Total
30
100.00
Freq.
Percent
Cum.
0
1
20
10
66.67
33.33
66.67
100.00
Total
30
100.00
PU/DSS/OTR
Freq.
Percent
Cum.
18 to 19
20 to 29
30 to 39
10
9
11
33.33
30.00
36.67
33.33
63.33
100.00
Total
30
100.00
. tab1
Freq.
Percent
Cum.
0
1
20
10
66.67
33.33
66.67
100.00
Total
30
100.00
Freq.
Percent
Cum.
0
1
21
9
70.00
30.00
70.00
100.00
Total
30
100.00
Freq.
Percent
Cum.
0
1
19
11
63.33
36.67
63.33
100.00
Total
30
100.00
PU/DSS/OTR
Source: http://www.ats.ucla.edu/stat/stata/notes2/commands.htm
PU/DSS/OTR
http://www.stata.com/support/faqs/stat/panel.html
http://www.stata.com/support/faqs/stat/xtreg.html
http://www.stata.com/support/faqs/stat/xt.html
http://dss.princeton.edu/online_help/analysis/panel.htm
PU/DSS/OTR
PU/DSS/OTR
PU/DSS/OTR
Books
Introduction to econometrics / James H. Stock, Mark W. Watson. 2nd ed., Boston: Pearson Addison
Wesley, 2007.
Data analysis using regression and multilevel/hierarchical models / Andrew Gelman, Jennifer Hill.
Cambridge ; New York : Cambridge University Press, 2007.
Econometric analysis / William H. Greene. 6th ed., Upper Saddle River, N.J. : Prentice Hall, 2008.
Designing Social Inquiry: Scientific Inference in Qualitative Research / Gary King, Robert O.
Keohane, Sidney Verba, Princeton University Press, 1994.
Unifying Political Methodology: The Likelihood Theory of Statistical Inference / Gary King, Cambridge
University Press, 1989
Statistics with Stata (updated for version 9) / Lawrence Hamilton, Thomson Books/Cole, 2006
PU/DSS/OTR