Hello!
Each row of my dataset represents a family, and within the family I have each family member's age listed under the variables age1 - age14. What I'd like to do is summarize how many people in the total dataset are under 5 years old, how many are 6 - 10 years, 11 - 15 etc. and compile it under one new variable called agegrp. Through past posts I was able to figure out the following command to successfully generate a new variable for all individuals in the sample that are under 6, but to generate a new variable for each age group seems like an inefficient way to go about this.
egen agegrp1 = anycount(age*), value(0,5)
I feel like this is likely a job for a loop of some sort but I can't seem to figure it out. Any guidance would be greatly appreciated!
Each row of my dataset represents a family, and within the family I have each family member's age listed under the variables age1 - age14. What I'd like to do is summarize how many people in the total dataset are under 5 years old, how many are 6 - 10 years, 11 - 15 etc. and compile it under one new variable called agegrp. Through past posts I was able to figure out the following command to successfully generate a new variable for all individuals in the sample that are under 6, but to generate a new variable for each age group seems like an inefficient way to go about this.
egen agegrp1 = anycount(age*), value(0,5)
I feel like this is likely a job for a loop of some sort but I can't seem to figure it out. Any guidance would be greatly appreciated!
Comment