I'm trying to sum up data in Stata. I have UK local authority codes (e.g. E06000047) and a dataset, which is deeper by a level (MSOA).
MSOA code MSOA name Local authority code Net weekly income
E02004297 County Durham 001 E06000047 480.00
E02004290 County Durham 002 E06000047 540.00
E02004298 County Durham 003 E06000047 520.00
E02004299 County Durham 004 E06000047 430.00
E02004291 County Durham 005 E06000047 400.00
Since I'm not interested in the MSOA-level-data i'd like to sum up the data to local auth code level. Where I fail is the fact that I can't calculate with string data. What I want to do is:
foreach identical "Local authority code" take the mean/median and
store it in a var "means.local-auth"
So what I expect is something like:
Local authority code means.local-auth median.local-auth
E06000047 474.00 480.00
E06000048 486.00 485.00