version 12.1 use https://www3.nd.edu/~rwilliam/statafiles/blwh.dta, clear tabstat income educ jobexp, by(black) columns(variables) quietly reg income educ jobexp if black==1 estimates store blackmodel quietly reg income educ jobexp if black==0 estimates store whitemodel quietly reg income educ jobexp estimates store bothmodel estimates table blackmodel whitemodel bothmodel * Using margins quietly reg income educ jobexp if black == 1 margins, at(educ = 13.9 jobexp = 14.1) * Appendix A - Other methods * Predict quietly reg income educ jobexp if black == 1 predict whcompblcoef if black==0 sum whcompblcoef * Adjust quietly reg income educ jobexp if black == 1 adjust educ jobexp if black == 0 * Margins, more precise approach sum educ if black == 0, meanonly scalar whitemeaneduc = r(mean) sum jobexp if black == 0, meanonly scalar whitemeanjobexp = r(mean) scalar list quietly reg income educ jobexp if black == 1 margins, at(educ = `=whitemeaneduc' jobexp = `=whitemeanjobexp') * Margins using atmeans quietly reg income educ jobexp if black == 1 margins if black == 0, noesample atmeans *Appendix B clear all use https://www3.nd.edu/~rwilliam/statafiles/goodpay.dta, clear tabstat goodpay occ1 occ2 occ3, by(female) columns(variables) * Margins reg goodpay occ2 occ3 if female == 1 margins, at(occ2 = .15 occ3 = .7) * Predict reg goodpay occ2 occ3 if female == 1 predict mcompfcoef if female == 0 sum mcompfcoef * Adjust quietly reg goodpay occ2 occ3 if female == 1 adjust occ2 occ3 if female == 0 * Margins using precise values sum occ2 if female==0, meanonly scalar malemeanocc2 = r(mean) sum occ3 if female==0, meanonly scalar malemeanocc3 = r(mean) scalar list quietly reg goodpay occ2 occ3 if female == 1 margins, at(occ2 = `=malemeanocc2' occ3 = `=malemeanocc3') * Margins using atmeans quietly reg goodpay occ2 occ3 if female == 1 margins if female == 0, noesample atmeans