global datadir http://personalpages.manchester.ac.uk/staff/mark.lunt/stats global datadir $datadir/2_summarizing_data/data use $datadir/pimax.dta, clear sort pimax browse * 1.1. Median = 95 * 1.2 Lower quartile = 75 * Upper quartile = 110 sort id gen sum = sum(pimax) browse gen n = _n gen mean = sum / n browse * 1.3 Mean = 92.6 drop mean egen mean = mean(pimax) gen diff = pimax - mean gen diff2 = diff*diff gen diff2_sum = sum(diff2) gen variance = diff2_sum / n gen sd = sqrt(variance) * 1.4 SD = 24.41 use "$datadir/htwt.dta", clear histogram bmi graph export bmi.eps, replace * 2.1 There appear to be some very high values of BMI: the distribution is not symmetrical summarize bmi, det * 3.2 Mean BMI = 26.1 * 3.3 The mean is slightly higher than the median, as you would expect from the skewness * 3.4 p25 = 22.6, p75 = 28.7 sort sex by sex: summ bmi, det graph box bmi, by(sex) graph export bmi_by_sex.eps, replace * 4.2 The median BMI and the lower quartile are both slightly higher in males * However, the upper quartile and range are very similar in men and women tabstat nurseht nursewt, by(sex) statistics(mean sd) * 5.1 Females, height: mean 159.8 cm, SD 6.4cm * weight: mean 65.9 kg, SD 12.8kg * Males, height: mean 173.0 cm, SD 6.9cm * weight: mean 78.8 kg, SD 12.2kg table sex, c(mean nurseht sd nurseht mean nursewt sd nursewt) * 6.1 Should be the same as 6.1 summarize age * 7.1 48.4 histogram age graph export age.eps, replace * 7.2 No, the distribution does not decrease at the ends * as a normal distribution would sort sex by sex: summ age, det * 7.3 Males 19 - 76, Females 19-74 summ bmi bmirep * 7.4 The mean of the reported BMI is less than the mean of the measured BMI gen bmidiff = bmi - bmirep summ bmidiff * 7.5 Mean = 1.1, SD = 1.8 histogram nurseht, by(sex) graph export nurseht_by_sex.eps, replace histogram nurseht, by(sex) normal graph export nurseht_by_sexn.eps, replace histogram nursewt, by(sex) graph export nursewt_by_sex.eps, replace histogram nursewt, by(sex) normal graph export nursewt_by_sexn.eps, replace