Stata: Trying to merge two data sets with common year observations I am currently trying to merge two datasets with a common "year" variable using Stata. One dataset is purely for incorporating CPI with an associated year, and so the only variables are "year" and "cpilevel". The other is our main dataset, and we are trying to merge the CPI-year dataset in order to create a new "cpilevel" variable in the main dataset associated with the same years. I am attaching photos of the CPI-specific dataset and a cross-section of the main dataset (there are far too many observations to capture the whole set). Please let me know the easiest way to merge these datasets; we have tried using m:1 codes but can't seem to get the right combination.





::EDIT::

Here are the results of the merge command. It did not accomplish what we need in terms of merging the "cpilvl" variable with the "year" variable in each of the main observations, but it seems to be on the right track?
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