Hi experts,
I would like to ask how to generate a new variable taking considering multiple variables.
For instance, let us assume there are three variables: id, year, and daily_income.
id means people on dataset
year 0 means the first year and year 1 means the second year.
daily income is the amount of income they get daily.

.
What I want to do is to create a new variable called "poverty_category" to categorize people like the following;
poverty_category = 1 if a person gets daily income more than 2 at both year 0 and year 1
poverty_category = 2 if a person gets daily income less than 2 at year 1 but gets daily income more than 2 at year 2
poverty_category = 3 if a person gets daily income more than 2 at year 1 but gets daily income less than 2 at year 2
poverty_category = 4 if a person gets daily income less than 2 at both year 0 and year 1
(For instance, if a person has 2 daily_income at year 1 and 2, he or she gets the value 1 for poverty_category )
To summarize, I want to create the new variable like below, but I am not sure how to get there. So, could you please help me to realize what I want to do?
I would like to ask how to generate a new variable taking considering multiple variables.
For instance, let us assume there are three variables: id, year, and daily_income.
id means people on dataset
year 0 means the first year and year 1 means the second year.
daily income is the amount of income they get daily.
.
What I want to do is to create a new variable called "poverty_category" to categorize people like the following;
poverty_category = 1 if a person gets daily income more than 2 at both year 0 and year 1
poverty_category = 2 if a person gets daily income less than 2 at year 1 but gets daily income more than 2 at year 2
poverty_category = 3 if a person gets daily income more than 2 at year 1 but gets daily income less than 2 at year 2
poverty_category = 4 if a person gets daily income less than 2 at both year 0 and year 1
(For instance, if a person has 2 daily_income at year 1 and 2, he or she gets the value 1 for poverty_category )
To summarize, I want to create the new variable like below, but I am not sure how to get there. So, could you please help me to realize what I want to do?

Comment