UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

Stata Class Notes 3.0
Getting Started in Statistics with Stata


getting started

use http://www.ats.ucla.edu/stat/stata/notes3/hsb2

describe

descriptive statistics / exploratory data analysis


summarize

summarize read write

summarize read, detail

tabulate prog, sum(read)

table prog, contents(n read mean read sd read)

stem read

histogram read

graph box read

frequency distributions & cross tabulation


tabulate read

tabulate prog

tabulate prog, nolabel

tab1 female prog ses

tabulate prog ses

tab2 prog ses female

by


sort prog

by prog: summarize read write math

sort female

by female: summarize read write math

over


graph bar read, over(prog)

graph box write, over(prog)

if


summarize read write math if ses=="high"

summarize read write math if ses=="3"

summarize read write math if ses==3

summarize read if ses==1 | ses==2

summarize read if ses~=3

summarize read if ses < 3

summarize read if female==2 & ses < 3

scatterplot & correlation


scatter read write

correlate read write math science

graph matrix read write math science, half

creating and modifying variables


generate total = read + write

summarize total

replace total = total + math

summarize total

generate honors = .
replace honors = 1 if write >= 60 & write < 100
replace honors = 0 if write >= 0 & write < 60

tabulate honors

generate highses = ses
recode highses 3=1 1 2=0
tabulate highses

entering your own data

You can enter your own data using Stata's data editor. Let's enter the following data into the data editor.

Smith       79       84
Jones       87       86
Brown       91       94
Adraktas    80       84


clear

edit

save mydata

You can also enter data using a text editor or word processor. Below is a data file called tdata.raw. It was created using a text editor and saved "plain" ascii text.

-------------------------------tdata.raw-----------------------

"Smith"       79       84
"Jones"       87       86
"Brown"       91       94
"Adraktas"    80       84
"Johnson"     78       83
"James"       86       82
"Scott"       90       93
"Sanders"     79       83
"Henderson"   77       82
"Allen"       85       84
"Murphy"      89       92
"Jackson"     78       82

---------------------------------------------------------------

clear

copy http://www.ats.ucla.edu/stat/stata/notes3/tdata.raw tdata.raw

infile str10 name midterm final using tdata.raw

save tdata

How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California