I want to create a new variable "dependent" that should include the count of the values from another variable "age". I run the following command but it doesn't work:
egen dependent = count(age <= 15 & age>=65), by(hhid).
Please help me to solve this problem. My data is like this:
And my results should be like this:
egen dependent = count(age <= 15 & age>=65), by(hhid).
Please help me to solve this problem. My data is like this:
hhid | age | sex |
1201 | 65 | 1 |
1201 | 22 | 2 |
1201 | 1 | 1 |
1201 | 11 | 2 |
1202 | 5 | 1 |
1202 | 45 | 1 |
1202 | 40 | 2 |
1203 | 36 | 2 |
1203 | 14 | 2 |
1203 | 34 | 1 |
And my results should be like this:
hhid | dependent (no) |
1201 | 3 |
1202 | 1 |
1203 | 1 |
Comment