Skip to Main Content

Data Analysis with Stata

reshape

reshape wide city sex, i(person) j(year) reshapes "long" data to "wide".

reshape long city sex, i(person) j(year) reshapes wide data to long.

Long data
Wide data
person year state sex
A 2010 CA male
A 2011 TX male
B 2010 OR female
B 2011 OR female
C 2010 IN male
C 2011 CA male
D 2010 MI female
D 2011 OR female
person state2010 sex2010 state2011 sex2011
A CA male TX male
B OR female OR female
C IN male CA male
D MI female OR female

Screencast produced by the Office of Digital Learning