Put it into Practice

Now it’s time to try things out for yourself. Complete each of the following steps, based on what we learned in this chapter.

Unless your instructor tells you otherwise, use an do-file to execute all code needed to accomplish the following:

  1. This exercise build directly on the one from Part 4. Once again, load in the Vulnerable Neighborhoods Survey dataset (vns.dta).1 You can download it here and save it on your computer. Or you can load the file directly into Stata through the Internet with the following URL: https://learndata.net/vns.dta
  1. Create a two-way frequency table with percentages by column (or row) for the variables perceived_discrim and gender. Then, create one for perceived_discrim and immstatus.

  2. Create bar charts that visualize the comparisons shown in both tables from the prior item.

  3. As in the Part 4 exercise, create a binary variable indicating perceived discrimination. “Yes” should be coded as 1, “No” should be coded as 0, and “Don’t know” should be coded as missing.

  4. Run a regression with the binary discrimination measure (created in step 4) as the dependent variable and gender and immstatus as independent variables. Make sure both independent variables are treated as factor (qualitative) variables.

  5. Run a regression with avg_disgust as the dependent variable and gender and immstatus as independent variables. Make sure both independent variables are treated as factor (qualitative) variables.

After completing all of this, you should save your do-file in a folder that is convenient to access. If you are submitting work to an instructor, they will likely want you to send them both your do-file and a Word doc containing your results.


  1. This is a modified version of data obtained from Sønderskov and colleagues: https://doi.org/10.17605/OSF.IO/62BV5 (CC-BY 4.0)↩︎