I have dataset1 with 1400 row and 25 columns, and dataset2 with 400 rows and 5 columns.Both datasets have a column called ID. as a small example, I can illustrate them like below:
dataset1:
ID c1 c2 c3 c4
12 m n 5 1/2/2015
5 c x 4 2/3/2015
45 g t 47 4/23/2015
45 j t 3 1/1/2016
61 t y 12 7/3/2015
3 r n 18 3/3/2015
dataset2:
ID a1 a2
45 1 1/1/2015
3 5 2/2/2016
12 12 4/29/2016
(as you can see ID in dataset2 is a subset of ID in dataset1)
what I want is: for each row of dataset1, if the value in column ID is equal to a value in the column ID of dataset2, then copy the corresponding value of the column a2 of that row of dataseset2 into a new column of dataset1 as below:
ID c1 c2 c3 c4 c5
12 m n 5 1/2/2015 4/29/2016
5 c x 4 2/3/2015 NA
45 g t 47 4/23/2015 1/1/2015
45 j t 3 1/1/2016 1/1/2015
61 t y 12 7/3/2015 NA
3 r n 18 3/3/2015 2/2/2016
I appreciate your help.