I have a dataset similar to Var1 Var2 Date1 Date2 Date3 A 1 1/1/2019 1/16/2020 1/30/2021 B 2 6/15/2018 6/30/2019 7/14/2020 C 2 5/26/2018 6/10/2019 6/24/2020 And I need to create a function that assigns a value depending on the values of a second dataset like the following Var2 Year Var3 1 2018 1000 1 2019 2000 1 2020 3000 1 2021 4000 2 2018 5000 2 2019 6000 2 2020 7000 2 2021 8000 The main idea is that if Var1 = A then the function assign the value of Var3 according to Var2 and the year of Date1, if Var1 = B then the function assigns the value in Var3 according to Var2 and the year of Date2 and if Var1 = C then the function assign the value in Var3 according to Var2 and the year of Date3. In order to get the following result: Var1 Var2 Date1 Date2 Date3 Var3 A 1 1/1/2019 1/16/2020 1/30/2021 2000 B 2 6/15/2018 6/30/2019 7/14/2020 6000 C 2 5/26/2018 6/10/2019 6/24/2020 7000 Thanks a lot for your help!
... View more