I have a question regarding generating a new variable in STATA. I am currently working on the IPUMS CPS dataset and interested in creating a variable of poverty threshold values for each of the years in my dataset (1996-2021). The value of the variable is based on the year, size of family unit, and related children under 18 years.
Following is an example of a code I run for each of the years:
Code:
. gen offcutoff_all = 0 . replace offcutoff_all = 7929 if year == 1996 & famsize == 1 & nchild == 0 . replace offcutoff_all = 10205 if year == 1996 & famsize == 2 & nchild == 0
So these two examples are for poverty threshold values if the year is 1996 and the family size is 1 with no child and then size is with 2 with no child and so on.
I do this for all the family sizes, all the children and all the years.
Now, the problem is that if I have a family of 4 with 2 children, both of whom are above 18 years then this code returns me a value which is different from the true value for the parents (as they state 2 children in the number of child variable but both the children are above 18). However, I get a correct value for children if they have 0 kids because my code returns me the value for 4 family size and 0 kids which is correctly identified.
Similarly if the householder is above 65 years of age then I am not able to generate the correct value (since households with 1 or 2 persons has different values based on whether householder is under 65 years or above) because I had already dropped observations with age below 18 years and above 65 years.
I am not sure how I can resolve this problem.
Would really appreciate any help in this regard.
Thank you!
0 Response to Problem in generating a new variable
Post a Comment