I have a dataset with the variables "id_1", "year", and "id_2." I would like to create a new variable "year_new" that takes the value of the variable "year" in row 1, if "id_2" has the same value as id_1 in row 1. Essentially, "year_new[_n]" (in row _n) is assigned the value of "year[_n-x]" if "id_2[_n]" = "id_1[_n-x]", where x is some number.
Code:
id_1 year id_2 year_new 909 2019 2 . . . 909 2019
0 Response to Assigning value from one variable to another if condition is met
Post a Comment