From categorical to indicator variables in Stata

April 27, 2019

It’s possible to create indicator variables from categorical variables as well, by using the tabulate command. Let’s have a look:

sysuse nlsw88, clear
tabulate race, gen(rc)

Here we appended the option gen(rc) which generated three indicator variables for us out of the categories in the race variable. Let’s rename and relabel these:

rename rc1 white
label variable white "white" 
rename rc2 black
label variable black "black"
rename rc3 other
label variable other "other"

Tabulating and re-labeling variables


Profile picture

Written by Johan Osterberg who lives and works in Gothenburg, Sweden as a developer specialized in e-commerce. Connect with me on Linkedin

2024 © Johan Osterberg