|Data preparation in Stata: Grouped means|
The data we use in this example are a sub-sample from the 1982 High School and Beyond Survey (Raudenbush, Bryk, 2002), and include information on 7,185 students nested within 160 schools: 90 public and 70 Catholic. Sample sizes vary from 14 to 67 students per school.
Raudenbush, S.W., Bryk, A.S., 2002, Heirarchical Linear Models, Thousand Oaks, CA. Sage.
Number of observations (rows): 7185
school: school identifier
The first few lines of hsb.dta
The hsb.dta dataset contains a variable ses for each student and the variable meanses which is the mean of the SES values for the students in this school. If this school level variable had not been made available with the data set it would need to be created. To create the mean value of 'ses' in Stata for each school based on the students in the sample, we would use the commands
Other links: Centre for e-Science | Centre for Applied Statistics