\begin{Schunk}
\begin{Sinput}
 merge(x = datX, y = datY, by.x = c("ID", "Year", "Quarter"), by.y = c("Country", "year", "Semester"), all = TRUE)
\end{Sinput}
\begin{Soutput}
   ID Year Quarter       pop illnesses percipitation      cars
1  UK 1990      Q1 10.053590 101.49592     10.516855 108.26258
2  UK 1990      Q2 10.351663  86.57469      8.704328  91.88460
3  UK 1991      Q1  9.329023 105.53303     10.054616 104.76248
4  UK 1991      Q2 10.277954 115.89963      9.215351 110.21258
5 USA 1990      Q1 10.583188 106.91171      9.413120  89.50647
6 USA 1990      Q2  8.693201 108.23795      8.167623 123.30512
7 USA 1991      Q1  9.459614 121.45065     10.888139 114.02705
8 USA 1991      Q2 11.947693  76.53056     11.593488 109.42601
\end{Soutput}
\end{Schunk}
