I have a database with about 10000 observations and with the following variables: weight, country of residence, gender and age. I want to compare a person’s weight to that of his/her reference group (same country, same gender, and relatively similar age). For each observation I want to compute the mean weight value of those persons with same gender, living in the same country, and with age ranging from 5 years below to 5 years above. I could do something like:
by country gender, sort: egen=mean(weight)
but I do not know how to handle the varying age range, which changes for each observation.
Any help is highly appreciated
by country gender, sort: egen=mean(weight)
but I do not know how to handle the varying age range, which changes for each observation.
Any help is highly appreciated
Comment