title: Awk compare 2 files and match 2 columns, get % difference between column 3s
body: <p>I have 2 files, with the formatting below.  I am trying to compare lines where columns 1 and 2 match and then get the difference in the 2 #'s that are in column 3.</p>
  
  <p>if file 2 column 3 is greater than file1 column 3, i would like a + at the end of the row<br>
  if file2 column is less than file 1 column 3, i would like a - at the end of the row<br>
  if either file column 3 is 0 i would like a * at the end of the row.<br>
  <br>
  I only want to print lines where the difference between the 2 columns is > 15% <br></p>
  
  <p>file1 </p>
  
  <pre><code>abc,1,472
  abc,2,536
  abc,3,652
  abc,4,512
  abc,5,474
  abc,6,266
  abc,7,520
  def,1,954
  def,9,538
  def,10,136
  def,11,341
  def,12,183
  def,13,1209
  def,14,365
  def,15,536
  def,16,979
  def,17,0
  xyz,1,547
  xyz,19,0
  xyz,20,0
  xyz,21,0
  xyz,22,0
  xyz,23,0
  xyz,24,0
  </code></pre>
  
  <p>File 2</p>
  
  <pre><code>abc,1,456
  abc,2,533
  abc,3,643
  abc,4,444
  abc,5,124
  abc,6,255
  abc,7,520
  def,1,954
  def,9,538
  def,10,435
  def,11,341
  def,12,155
  def,13,1209
  def,14,365
  def,15,536
  def,16,979
  def,17,0
  xyz,1,547
  xyz,19,124
  xyz,20,0
  xyz,21,0
  xyz,22,0
  xyz,23,0
  xyz,24,0
  </code></pre>
  
  <p>expected output</p>
  
  <pre><code>abc,5,474,124,74%,-     // (474-124)/474 = 74%
  def,10,136,435,31%,+.   // (435-136)/474 = 69%
  xyz,19,0,124,100%,*.    // either file has 0 , print 100% and *
  </code></pre>
  
  <p>I have tried multiple iterations of this but cannot seem to get the formatting to work.</p>
  
  <pre><code>  awk -F, 'FNR==NR{a[$1,$2]; next ;b[$1,$2,$3]; next} $1,$2 in a {if ($3&gt;b[$3]) {Q=((b[$3]/$3) *100)) {print Q,$0 }} else if (b[$3]&gt;$3) {Q=(($3/b[$3]) *100)){print Q,$0 }}' file1 file2
  </code></pre>
  
  <p>i get this error<br>
  ^ unexpected newline or end of string<br></p>
  
  <p>also tried variations on this line but i cannot figure out the division by 0 error</p>
  
  <pre><code>awk -F, 'FNR==NR{a[$1,$2]; next ;b[$1,$2,$3]; next} $1,$2 in a {if ((Q=(b[$3]/$3) &gt; 15) || (Q=($3/b[$3])) &gt; 15 ){print Q,$0}}' file1 file2 
  awk: cmd. line:1: (FILENAME=file2 FNR=1) fatal: division by zero attempted
  </code></pre>