****************************************** Getting started with Stata mini-course May 2015 Twaweza Dar es Salaam, Tanzania ****************************************** Congratulations! You have survived all three lectures of the "Getting started with Stata" mini-course! You can now count yourself a self-sufficient Stata user, ready to create basic summary statistics tables, explore data, and learn more commands. The final homework will be a little different, and perhaps more challenging. We're going to practice the three important concepts we learned about: - Combining datasets with MERGE. - Avoiding copy+paste, and instead using LOOPS. - Seeing how we can use MACROS. For this homework, you will need to download: 1. The Sauti za Wananchi baseline dataset (szw-baseline.dta). 2. The Sauti za Wananchi constitution round dataset (szw-constitution.dta). Please complete the following tasks, saving your work in a .do file which you will send to me. Remember! Your .do file must: - Not have any errors which make it break. - Be able to be run on my machine with minimal input from me (so no debugging from me!). - Have lots of comments which explain what you're doing at each step. *************************************************************************************************** *********************** HERE ARE YOUR TASKS! ****************************************************** *************************************************************************************************** 1. Open and save a .do file, saving it as homework3+[your initials].do. 2. Create a header section, in comments, explaining who is writing this .do file, what it's for, what data it uses, and what data it creates. More comments = more points. 3. Include a preamble section, preparing your computer (or another user's computer) to run this .do file. 4. Create a --global-- macro, named "filepath", which points to the folder where your data is stored. Use --$filepath-- whenever you --use-- and --save-- datasets. (For a reminder on how to do this: see the Homework 2 solution video. Also, see the Lecture 2 slides.) 5. Include a log section: save this session in Stata using "log3+[your initials].txt". 6. Import the Sauti za Wananchi constitution data. 7. Rename all the variables from q1 to q13b with _const. So q1 becomes q1_const, q2 becomes q2_const, and so on. (Try to use a loop here!) 8. Save this new dataset as szw-constitution-merge.dta. 9. Import the Sauti za Wananchi baseline data. 10. Merge the baseline dataset with szw-constitution-merge.dta. Make sure you merge on a unique identifier. This must be a variable which is (1) used in both datasets, and (2) never repeats a value (so, one value per observation - i.e. it's unique!). 11. Drop all the observations that did not merge, i.e. keep only those that appeared in both the baseline and constitution datasets. 12. DATA CLEANING: Convert q12_const (question 12 in the constitution questionnaire) into a dummy, where it is 1 if a person plans to VOTEFOR the new constitution, 0 if they plan to VOTE AGAINST, and . (missing) for everything else. 13. DATA CLEANING: Convert q1_const (question 1) into a dummy, where it is 1 if a person said YES, and 0 if a person said NO. (Hint: You can write this in one line of code using --recode--!) 14. DATA ANALYSIS: Is average awareness of the constitutional review process different for men than for women? 15. BONUS/OPTIONAL: Is this difference in means statistically significant? Use a t-test to check for this (--help ttest--). 16. Save your .do file - and email it to me!