I am basically updating/creating a bunch of data tables and graphs for a presentation, so nothing too complex. However, I am having some issues dropping observations after a merge on Stata 11.2, and I can't figure out what the issue is exactly. I've searched online but I couldn't find anything for my error message that wasn't directly related to the merge itself, which my error doesn't seem to be. Any help or direction towards further resources is greatly appreciated.
After merging two data sets 1:1 by month and year (there are 12 months listed numerically for every year, but in combination they work as unique identifiers), when I try to drop values from before 1980 as well as values after month 7 and year 2015 I get the error message "variables year month do not uniquely identify observations in the using data."
Here is a copy of the section of the code where the error occurs:
The error message pops up right after "drop if year > ${current_y}".
Concerned about duplicates, I ran a duplicates report for year month on the merged dataset before and after the readin commands. There were no duplicates. I also checked "isid year month" and had no error messages, which makes sense considering the 1:1 merge. I also checked for duplicates from the original datasets before the initial merge, as I had just recently updated it. There were no duplicates. Here is a screen shot of the output after the final readin.
Array
Considering this, I figured stata was having issues with year and month working as unique identifiers on their own, as I am dropping observations based on their response in year and month as variables on their own not together. When I ran similar checks on duplicates and isid on year and month independently, I unsurprisingly had error messages and copies galore thanks to how I organized my data. A partial screenshot of 5 of my observations shows a little more clearly how I have the data organized and why I have duplicate months and years independently and not in combination.
Array
I never considered that stata would require observations to have unique identifiers for a drop as I am trying to accomplish here. Do you all know what the reasoning behind this is, if that is even the problem here? Also, if within reason, is there some way for me to get around that? Otherwise, I am thinking of dropping variables by using _n, but that would be less than ideal as I hope to use this code to update my presentation with new data as required. Do you have any recommendations on how to accomplish this in a more efficient manner?
Thanks for your help!

After merging two data sets 1:1 by month and year (there are 12 months listed numerically for every year, but in combination they work as unique identifiers), when I try to drop values from before 1980 as well as values after month 7 and year 2015 I get the error message "variables year month do not uniquely identify observations in the using data."
Here is a copy of the section of the code where the error occurs:
:
use ${outputdir2}temp_ir , replace ; sort year month; program define readin; sort year month; merge 1:1 year month using ${outputdir2}temp_`1'; drop _merge; save "${outputdir2}scrap1.dta" , replace ; end; readin `ei'; readin `cpi'; readin `hpi_us_ofheo'; readin `hpi_us_cs'; readin `fedtax'; readin `bea_income_nat' drop if year > ${current_y}; drop if year == ${current_y} & month > ${current_m}; drop if year < 1980; drop if year == .; sort year month;
Concerned about duplicates, I ran a duplicates report for year month on the merged dataset before and after the readin commands. There were no duplicates. I also checked "isid year month" and had no error messages, which makes sense considering the 1:1 merge. I also checked for duplicates from the original datasets before the initial merge, as I had just recently updated it. There were no duplicates. Here is a screen shot of the output after the final readin.
Array
Considering this, I figured stata was having issues with year and month working as unique identifiers on their own, as I am dropping observations based on their response in year and month as variables on their own not together. When I ran similar checks on duplicates and isid on year and month independently, I unsurprisingly had error messages and copies galore thanks to how I organized my data. A partial screenshot of 5 of my observations shows a little more clearly how I have the data organized and why I have duplicate months and years independently and not in combination.
Array
I never considered that stata would require observations to have unique identifiers for a drop as I am trying to accomplish here. Do you all know what the reasoning behind this is, if that is even the problem here? Also, if within reason, is there some way for me to get around that? Otherwise, I am thinking of dropping variables by using _n, but that would be less than ideal as I hope to use this code to update my presentation with new data as required. Do you have any recommendations on how to accomplish this in a more efficient manner?
Thanks for your help!