Stata: Trying to merge two data sets with common year observations
Have a file open in your current stata session. in your case let's say the file opened is M&amp;D Research Project one.
On the top option bar mentioning 'File', 'Edit' etc. go to 'Data' -> 'Combine Datasets' -> 'Merge two Datasets'
In Type of merges choose 'Many-to-One' since your currently open dataset is 'M&amp;D' having multiple year observations that have to merge with one observation per year in your 'cpi' dataset. 
In 'Key Variables' mention the name of the column to match/merge the data with. In your case it's 'year'.
Choose the file 'cpi' under 'Filename of dataset on disk'.


You'll have your resultant data.

NOTE: You may have to make sure the order of the year on both datasets is sorted

Also if you want to merger cpi with M&amp;D and not vice versa, open cpi dataset first and choose many to one relation. The rest of the steps are same