title: one-to-many merge in SAS (with mismatching records)
body: <p>I'm trying to do a merge in SAS which seems like it should be easy, but thus far haven't found anything that points to how to do it. I have two datasets - let's call them Monthly1 and Quarterly2. Monthly1 is the main one, and I want to merge Quarterly2 onto it. The problem is, the latter has a different periodicity, as the name implies. Here is what each looks like:</p>
  
  <p>MONTHLY1:</p>
  
  <pre><code>id,month,year,qname,data1,data2,data3,data4
  
  1111,01,2018,First Quarter 2018,27,33,55
  1111,02,2018,First Quarter 2018,28,34,54
  1111,03,2018,First Quarter 2018,28,37,51
  1111,04,2018,Second Quarter 2018,28,30,59
  1112,01,2018,First Quarter 2018,1,7,12
  1112,02,2018,First Quarter 2018,2,7,10
  1112,03,2018,First Quarter 2018,5,6,7
  1112,04,2018,Second Quarter 2018,4,1,8
  </code></pre>
  
  <p>QUARTERLY2:</p>
  
  <pre><code>id,qname,data4,data5
  
  1111,First Quarter 2018,53,7
  1111,Second Quarter 2018,58,9
  1112,First Quarter 2018,7,7
  1112,Second Quarter 2018,7,9
  </code></pre>
  
  <p>Merging on <code>id</code> and <code>qname</code>. So for each <code>month</code> in MONTHLY1, <code>data 4</code> is overwritten using the value in QUARTERLY2, and <code>data 5</code> is added as a new variable. The final dataset should look like (I've added a <code>*</code> where data from QUARTERLY2 is either added or overwritten):</p>
  
  <p>MERGED3:</p>
  
  <pre><code>id,month,year,qname,data1,data2,data3,data4,data5
  
  1111,01,2018,First Quarter 2018,27,33,53*,7*
  1111,02,2018,First Quarter 2018,28,34,53*,7*
  1111,03,2018,First Quarter 2018,28,37,53*,7*
  1111,04,2018,Second Quarter 2018,28,30,58*,9*
  1112,01,2018,First Quarter 2018,1,7,7*,7*
  1112,02,2018,First Quarter 2018,2,7,7*,7*
  1112,03,2018,First Quarter 2018,5,6,7*,7*
  1112,04,2018,Second Quarter 2018,4,1,7*,9*
  </code></pre>
  
  <p>Thanks!</p>