capture log close log using icpsrcda-statastarted, replace text // program: icpsrcda-statastarted.do // task: Getting Started in Stata // project: ICPSR CD // author: slr \ last revised 15July2009 // #1 // program setup version 10 clear all set linesize 80 matrix drop _all // #2 // Exploring Your Data *Importing/Using data *load data from the internet using spex command spex icpsr_scireview3, clear *save the data to your working directory save icpsr_scireview3_slr, replace *clear Stata's memory, and then load the data using the use command clear use icpsr_scireview3_slr, clear *look at a list of Stata example datasets sysuse dir *look at the spreadsheet of your data browse *Names, Labels, and Summary Statistics nmlab describe summarize codebook, compact codebook female phd summarize female phd, detail *Listing observations sort totpub list id totpub female phdclass jobprst enrol in 1/5 list id totpub female phdclass jobprst enrol if totpub==0 list id totpub female phdclass jobprst enrol in -5/L *Variable distributions tabulate female, miss tabulate phdclass female, miss tab1 phdclass female, miss histogram phdclass, freq twoway scatter phd totpub graph matrix female phd totpub, half graph export icpsrcda-statastarted-fig1.png, replace // #4 // Data Management *generating new variables gen totcit = cit1 + cit3 + cit6 + cit9 list cit1 cit3 cit6 cit9 totcit in 1/5 gen phdcat = phd recode phdcat (.=.) (1/1.99=1) (2/2.99=2) (3/3.99=3) (4/5=4) tab phdcat, miss gen workres = work recode workres (.=.) (1=0) (2=1) (3=0) (4=1) (5=0) *replace workres = 1 if work==2 | work==4 *replace workres = 0 if work==1 | work==3 | work==5 tab work workres gen workres2 = (work==2 | work==4) if (work<.) tab work workres2 *labeling variables label var totcit "Total # of citations" label var phdcat "Phd Prestige: categories" label var workres "Work as a researcher? 1=yes" label var workres2 "Work as a researcher? 1=yes" *value labels label define phdcat 1 "1_Adeq" 2 "2_Good" 3 "3_Strong" 4 "4_Dist" label value phdcat phdcat label define workres 0 "0_NotRes" 1 "1_Resrchr" label value workres workres label value workres2 workres *check labels tab phdcat tab workres tab workres2 // #5 // Beyond the Basics *storing estimates & creating tables using eststo, estadd, and esttab logit faculty fellow mcit3 phd eststo full logit faculty fellow mcit3 eststo nophd esttab full nophd, mtitles(Full NoPhD) esttab full nophd using icpsrcda-statastarted-table1.rtf, /// mtitles(Full NoPhD) b(%9.3f) replace *including odds ratios in the table: estadd expb: full nophd estadd ebsd: full nophd esttab full nophd, mtitles(Full NoPhd) cells(expb ebsd) replace esttab full nophd using icpsrcda-statastarted-table2a.rtf, /// mtitles(Full NoPhd) cells("expb(fmt(3))" "ebsd(fmt(3))") replace *including bic and aic esttab full nophd, mtitles(Full NoPhd) cells(expb ebsd) stats(bic aic) replace esttab full nophd using icpsrcda-statastarted-table2b.rtf, /// mtitles(Full NoPhd) cells("expb(fmt(3))" "ebsd(fmt(3))") /// stats(N bic aic) replace *using Stata as a Calculator display 2+2 di 2^5 di exp(2.915) di ln(exp(2.915)) *data Labels and notes label data "Biochemist data - updated for stata review - SLR" note: icpsr_scireview3_slrV2.dta \ Revised biochemist data adding vars /// totcit, phdcat, workres, and workres2 \ icpsrcda-statastarted.do /// slr 2009-05-19. note totcit: created by adding cit1 cit3 cit6 cit9 \ /// icpsrcda-statastarted.do slr 2009-05-19. save icpsr_scireview3_slrV2, replace clear use icpsr_scireview3_slrV2, clear notes _dta note totcit *locals local tag "icpsrcda-statastarted.do slr 2009-05-19" note workres: created from work \ `tag'. note workres local rhs "faculty enrol phd" regress totpub `rhs' log close exit