Presentation is loading. Please wait.

Presentation is loading. Please wait.

STATA Mini Course Fall 2015 Jane Leber Herr Littauer 113 1Stata Mini Course – Spring 2015.

Similar presentations


Presentation on theme: "STATA Mini Course Fall 2015 Jane Leber Herr Littauer 113 1Stata Mini Course – Spring 2015."— Presentation transcript:

1 STATA Mini Course Fall 2015 Jane Leber Herr jlherr@fas.harvard.edu Littauer 113 1Stata Mini Course – Spring 2015

2 Goal: Make you comfortable with Stata 1)Can’t teach you all of Stata 2)But can teach you basics AND 3)Teach you how to teach yourself Stata 2 The Stata Mini-Course Stata Mini Course – Spring 2015

3 Why is Stata so AWESOME? Let me count the ways… 1)In Excel, you can’t produce a step-by-step record. In Stata,.do files do exactly that! Why is that important? Can remind yourself what you did (and why) Can tweak one thing, and rerun – Ta Da! Can easily find bugs in your code 3 Why use Stata?? Stata Mini Course – Spring 2015

4 Why is Stata so AWESOME? Let me count the ways… 1)In Excel, you can’t produce a step-by-step record In Stata,.do files do exactly that! 2)Excel is MUCH slower at manipulating data 3)Stata produces much nicer graphs 4)Excel can’t handle econometrics the way Stata can! How much data manipulation ok in Excel? NONE! 4 Why Stata?? Stata Mini Course – Spring 2015

5 1)Stata mini-course lectures & problem sets Class Dates: Tuesday 2/24 Tuesday 3/10 Tuesday 3/31 Problem Set Dates: Friday 2/20 Friday 3/6 Friday 3/27 Friday 4/10 5 Stata Course Structure Stata Mini Course – Spring 2015

6 2)Stata office hours (see isite) 6 Stata Course Structure Stata Mini Course – Spring 2015

7 3)Help by email We will try to respond to emails ASAP, but goal: Within 24 hours during the week By Monday if over the weekend Google your question! Email etiquette: If you email both of us, do it in a way that we can tell (then we can cc: each other/not duplicate effort) If you figure out the answer on your own, let us know! 7 Stata Course Structure Stata Mini Course – Spring 2015

8 Resources available on the isite: Class schedule and pset due dates Announcements (e.g., OH switches) Our contact info OH schedule (appointment sign up) Lecture materials Problem Sets Other AWESOME resources 8 Stata iSite Stata Mini Course – Spring 2015

9 Download from HUIT (see details in PSet #1) Keyserver Client (IMPORTANT!) Stata (tips on how to figure out which version you need) Harvard VPN Help? Email HUIT (ithelp@harvard.edu)ithelp@harvard.edu Science Center Computer lab 9 Downloading Stata Stata Mini Course – Spring 2015

10 Stata Windows: Command line Results panel Variables List of commands you’ve run so far 10 What is Stata? Stata Mini Course – Spring 2015

11 Most awesome part of Stata! – File that holds all the commands you want Stata to run – Can be a file that: Builds your dataset & variables Runs all your regressions Builds your results tables Builds your figures Or any combination! – You will build a.do file for each Stata pset 11.do files! Stata Mini Course – Spring 2015

12 Where is the.do file? –.do file button – Window: “do file editor” 12.do file example Stata Mini Course – Spring 2015

13 Saving the results in a.log file – log using example.log … log close – For Stata psets, will send your instructor: your.do file the.log file it creates that holds all the results 13.log file Stata Mini Course – Spring 2015

14 1)Comment at top (e.g., purpose of the.do file) Comments: * /* */ 2)Save the.do file:.do files do NOT autosave – SAVE FREQUENTLY! 14 Let’s build a.do file… Stata Mini Course – Spring 2015

15 3)Change the working directory (folder): Easiest if working in the directory where the data live Current directory shown at bottom left Short-cut Tip #1: – Change directory in “File/Change Working Directory” – Can now see path name in Results window – Copy that line of code into the.do file you are building 15 Let’s build a.do file… Stata Mini Course – Spring 2015

16 4)Start a.log file log using Stata_Lect1.log 16 Let’s build a.do file… Stata Mini Course – Spring 2015

17 Aside: How tell Stata run command from.do file?? 1)Choose File/“do”: Will run the WHOLE.do file 2)Choose “execute” button from.do file: If nothing highlighted: will run whole.do file If lines highlighted: will run JUST those lines 3)Highlight (partial) line: If PC: control D If mac: control shift D 17 Let’s build a.do file… Stata Mini Course – Spring 2015

18 5)Open a dataset use StataClass_Raw 6)Let’s look at the data! browse 18 Let’s build a.do file… Stata Mini Course – Spring 2015

19 5)Open a dataset use StataClass_Raw 6)Let’s look at the data! browse describe summarize 19 Let’s build a.do file… Stata Mini Course – Spring 2015

20 Figuring out how a command works: Link to even MORE help! Command syntax: summarize [varlist], …options List of options Descriptions EXAMPLES! If don’t know command name: – “search blah” – Google it! 20 Stata help files Stata Mini Course – Spring 2015

21 5)Open a dataset use StataClass_Raw 6)Let’s look at the data! browse describe summarize summarize uhrswork, detail 21 Let’s build a.do file… Stata Mini Course – Spring 2015

22 5)Open a dataset use StataClass_Raw 6)Let’s look at the data! browse describe summarize summarize uhrswork, detail tabulate nchild if age>=20 & age<=30 tabulate nchild, nolabel 22 Let’s build a.do file… Stata Mini Course – Spring 2015

23 7)Build variable “female”: tab sex generate female = 1 if sex==“female” tab sex, nolabel generate female = 1 if sex==2 browse the data (browse sex female) notice “missing values” for the men (no values for them if “tab female”) replace female = 0 if sex==1 (redo “tab female”) 23 Lets build a variable! Stata Mini Course – Spring 2015

24 8)Cut data down to size: Drop the men Keep if age>=30 & age<=40 9)Save updated dataset: Do NOT call by same name as before! save StataClass_Lect1 Rerun from the start… 24 Saving Data Stata Mini Course – Spring 2015

25 10) Explore hours worked by # of kids: sum uhrswork if nchild==0 sum uhrswork if nchild>0 bysort nchild: sum uhrswork 11)Close the.log file Rerun from the start… 25 Exploring Hrs Worked by #Kids Stata Mini Course – Spring 2015

26 ASIDE: Capitalization matters! Commands: Summarize ≠summarize Variable names: Age ≠age 26 Useful things to know… Stata Mini Course – Spring 2015

27 Useful things you learn: 1)Other ways to build variables (e.g., using tabulate) 2)Labeling variables 3)Other useful commands 4)Lots of other tips that will be invaluable for doing the psets 27 Other things shown in the “clean”.do file: Stata Mini Course – Spring 2015


Download ppt "STATA Mini Course Fall 2015 Jane Leber Herr Littauer 113 1Stata Mini Course – Spring 2015."

Similar presentations


Ads by Google