What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label...
Transcript of What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label...
![Page 1: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/1.jpg)
ukdataservice.ac.uk
What is Stata?
![Page 2: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/2.jpg)
![Page 3: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/3.jpg)
![Page 4: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/4.jpg)
![Page 5: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/5.jpg)
. set memory 20m, permanently
. set mem 20m, perm
. use <filename>, clear
![Page 6: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/6.jpg)
<filename>
. cd C:\Data_Stata
use <filename>
![Page 7: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/7.jpg)
![Page 8: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/8.jpg)
. lookfor hours
. describe
. clear
. rename var1 = id
. label var id “identification no.”
. renvars v*\id sex age income
. compress
![Page 9: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/9.jpg)
. describe numchild04
. de numchild04
![Page 10: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/10.jpg)
. codebook ten1
. help describe
. findit describe
![Page 11: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/11.jpg)
. save <filename>
. save, replace
![Page 12: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/12.jpg)
. log using <filename>
<filename>
<filename> <filename>
<filename>.
. log off
. log on
. log close
. tabulate sexx
![Page 13: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/13.jpg)
. ta sexx
. tabulate sexx, nolabel
. tab1 sexx marcivx fbx
![Page 15: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/15.jpg)
. mvdecode <variable>, mv(<value>)
. mvdecode jobtyp, mv(-8, -9)
. mvdecode jobtyp, mv(-8=.a \ -9=.b)
. mvdecode _all, mv(-8=.a \ -9=.b)
mvencode
. mvencode _all, mv(.a=-8 \ .b=-9)
. tab marcivx sexx, r m
![Page 16: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/16.jpg)
tab2
. tab2 marcivx fbx sexx, r m
![Page 17: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/17.jpg)
. tab2 marcivx sexx, chi2
. table marcivx fbx sexx
. sum hourpay
. sum hourpay, detail
![Page 18: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/18.jpg)
. sum hourpay if sexx==1, detail
![Page 19: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/19.jpg)
. ta marcivx sexx if (statusx==1& hourpay>0), su(hourpay) means
. bysort ages: tabulate marcivx sexx if (statusx==1&hourpay>0), su(hourpay) means
nofreq
![Page 20: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/20.jpg)
![Page 21: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/21.jpg)
. ta sexx marcivx [fweight=pwt11]
. ta sexx marcivx [fw=pwt11]
. table marcivx sexx if (statusx==1&hourpay>0), c(mean hourpay) format(%9.2f)
![Page 22: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/22.jpg)
. ta sexx marcivx [w=pwt11]
. help weight
![Page 23: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/23.jpg)
. generate sex1=sexx
. label variable sex1 “sex of respondent”
. label define sexlabel 0 male 1 female
. label values sex1 sexlabel
label define
. gen sex2=sexx
. label values sex2 sexlabel
. rename sex2 sex3
![Page 24: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/24.jpg)
. gen agesquared=age^2
. gen weekpay=hourpay*35
. gen age40_a=age >=40 if age ~=.
. gen age40_b=cond(age >=40, 1,0) if age ~=.
. tab age40_a age40_b
. gen age40=1 if age >=40
. replace age40=0 if age40 ~=1 & age ~=.
. help reswords
. help _variables
![Page 25: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/25.jpg)
. label define AGEG40 1 “Aged 40 or older” 0 “Less than 40”
. label values age40 AGEG40
. codebook ethukeul
. gen white = ethukeul
. recode white 1=1 2/9=0 *=.
. label variable white "White versus non-white"
. replace varx=1 if varz>4000
. replace varx =1 if varz > 4000 & varz ~= .
![Page 26: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/26.jpg)
. label define WHITE 1 "White" 0 "Non-white"
. label values white WHITE
. tab eth white
. codebook age
. gen agegroup=age
. recode agegroup min/19=1 20/29=2 30/39=3 40/49=4 50/59=5 60/65=6 *=.
. label variable agegroup "age in 10-year groups"
. label define AGEGGROUP 1 "16-19yrs" 2 "20-29yrs" 3 "30-39yrs" 4 “40-
49yrs” 5 “50-59yrs” 6 “60-69yrs”
. label values agegroup AGEGGROUP
. tab age agegroup
. recode ethukeul 1=1 2/9=0 *=., generate(white)
![Page 27: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/27.jpg)
![Page 28: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/28.jpg)
![Page 29: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/29.jpg)
. histogram hourpay
. histogram hourpay if hourpay >0 & hourpay <200 [fw=pwt11], bin(30) percent
scheme(s2color) title(Hourly pay (pounds))
. help histogram
![Page 30: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/30.jpg)
. twoway scatter hourpay
. twoway (scatter hourpay age if hourpay>0 & hourpay<=200), title(Women's
hourly pay (pounds) by age) subtitle (hourly pay>0 and <= 200 pounds)
note("Source: Labour Force Survey, October-December 2012.”)
. help graph
![Page 31: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/31.jpg)
![Page 32: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/32.jpg)
use <filename>, clear
set more off
sum hourpay if hourpay>0
tab sexx if hourpay>0, sum(hourpay)
end of do-file
![Page 33: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/33.jpg)
![Page 34: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/34.jpg)
![Page 35: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/35.jpg)
1
![Page 36: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/36.jpg)
. tab sex ten1 if hrp==1, col
. keep if hrp==1
. save <newfilename>
. tab hrp
![Page 37: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/37.jpg)
. sort aacode
. collapse (max) oldest=age, by(aacode)
. save <newfilename2>
. sort aacode
. egen oldest = max(age), by(hserial)
. bysort hserial: egen oldest = max(age)
. sort aacode
. merge 1:m aacode using <other file>
. sort aacode
. merge aacode using <householdfile.dta>
![Page 38: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/38.jpg)
. ta _merge
![Page 39: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/39.jpg)
. use <interviewfs11.dta>, clear
. sort aacode
. save <interviewfs11.dta>, replace
. clear
. use <generalfs11.dta>, clear
. sort aacode
. save <generalfs11.dta>, replace
. joinby aacode using <interviewfs11.dta>
. save <household11.dta>, replace
![Page 40: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/40.jpg)
. use <generalfs10.dta>, clear
. ge year= 2010
. save <year10>, replace
. clear
![Page 41: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/41.jpg)
. use <generalfs11.dta>, clear
. ge year= 2011
. save year11, replace
. append using year10
. save years1011, replace
. sort year
. duplicates report aacode
. duplicates report aacode year
![Page 42: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/42.jpg)
. help estimation commands
. help estcom
. regress depvar [varlist] [weight] [if exp] [in range] [, level(#) beta robust
noconstant noheader]
. help regress
![Page 43: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/43.jpg)
. char ethukeul [omit]1
![Page 44: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/44.jpg)
. xi: regress grsswk i.ethukeul if statusx==1 & grsswk~=.
. est store model1
. xi: regress grsswk i.eth i.sexx i.marcivx if status==1& grsswk~=.
![Page 45: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/45.jpg)
. est store model2
. xi: regress grsswk i.eth sexx marc if status==1& grsswk~=.
. est query
. est dir
![Page 46: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/46.jpg)
. est replay model1
. est restore model1
. est table model1 model2, star eform
. testparm _Is* _Ima*
![Page 47: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/47.jpg)
. test _Iethukeul_3=_Iethukeul_4
. test _Iethukeul_3=_Iethukeul_5
. help testparm
. help test
. help logit postestimation
. help postestimation commands
![Page 49: What is Stata? - UK Data Service · . lookfor hours . describe . clear . rename var1 = id. label var id “identification no.”. renvars v*\id sex age incomecompress](https://reader031.fdocuments.us/reader031/viewer/2022022119/5d1e8e7e88c9936f5d8ba5aa/html5/thumbnails/49.jpg)
16 May 2014
T +44 (0) 1206 872143E [email protected] ukdataservice.ac.uk
The UK Data Service delivers quality social and economic data resources for researchers, teachers and policymakers.
© Copyright 2014 University of Essex and University of Manchester