|
|
|
||||
|
|
|||||
use http://www.ats.ucla.edu/stat/stata/notes/hsb2 describe
summarize summarize read write summarize read, detail tabulate prog, sum(read) table prog, contents(n read mean read sd read) stem read graph read, hist bin(20) graph read, box
tabulate read tabulate prog tabulate prog, nolabel tab1 female prog ses tabulate prog ses tab2 prog ses female
sort prog graph read, box by(prog) by prog: summarize read write math graph read,bar mean by(prog) graph write,bar mean by(female) sort female graph write,bar mean by(female)
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
graph read write graph read write, xlabel ylabel graph read write, twoway box xlabel ylabel correlate read write math science graph read write math science, matrix half
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
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/notes/tdata.raw tdata.raw infile str10 name midterm final using tdata.raw save tdata
More Stata Class Notes are available on the World Wide Web by visiting ...
http://www.ats.ucla.edu/stat/stata/notes/
The dataset hsb1.dta can be loaded directly into Stata, over the Internet, using the
following command:
use http://www.ats.ucla.edu/stat/stata/notes/hsb1
Note: .dta is the extension for Stata-format files. Stata automatically includes .dta on files when they are saved. You do not have to include the .dta when reading datasets using Stata.
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