Q:

awk: Print out file 1 based on file2, and add column from file 2 and discard rows in file 1 depending on matching columns

I'd like to print out file 1 based on file 2. Here are the job details:
First csv file, named as "file1_ab.csv":  
a,  b,  20  
a1, b1, 5  
a2, b2, 8  
a5, b5, 30  

second csv file, named as "file2_ab_compare.csv":
a,  b,  ID_100  
a4, b4, ID_400  
a2, b2, ID_200  

I would like to use second csv file as filter to conditionally print out the first csv file following the logics like this:
1). if $1$2 of file 1 is the same as that file 2, such as row 1 of file1, print out row 1 of file1 plus the $3 of file 2 (forming column 4). For example: 
a, b, 20, ID_100 

2). if $1$2 of file 1 doesn't exist in that of file 2, I'd like to selectively print out that row of file 1 depending on the value of its $3.
for example:  
$3 of row 2 of file 1 (5) is smaller than 15, then, I will discard this row. (so, row 2: a1,b1, 5 were not in the output file).
On the other hand,
$3 of row 4 of file 1 (30) is greater than 15, then, I will print out this row, and put "na" in column 4.
So, the final output should be like this:
a,  b,  20, ID_100  
a2, b2, 8,  ID_200  
a5, b5, 30, na 

I wrote a code like this, named as "filter.awk":
#!/usr/bin/awk -f
BEGIN {FS=","}
NR==FNR{a[$1$2]=$3;next}
{
if ($1$2 in a) print $0","a[$1$2];
else
    if {$3 > 15} print $0",""na";}
    else {next}
}

I run this code like:  
awk -f filter.awk file2_ab_compare.csv file1_ab.csv

But it said that there is syntax error. I have tried to modify this code many times by searching solutions on stackoverflow, but never got it worked out. 
I would greatly appreciate your kind help!
BTW, is this kind work is too hard to use awk? Should I try Python in case like this?

A:

awk -F, 'BEGIN{OFS=","} NR==FNR{a[$1$2]=$3;next} ($1$2 in a){print $0, a[$1$2]} !($1$2 in a){if($3>15){print $0, " na"}}' file2_ab_compare.csv file1_ab.csv

BEGIN{OFS=","} sets the output field separator to comma.
NR==FNR{a[$1$2]=$3;next} saves 3rd column as array value and $1$2 as key for the first input file. 
($1$2 in a){print $0, a[$1$2]} checks second inputs $1$2, if it exists in array, prints the whole line of second input file and the array value.
!($1$2 in a){if($3>15){print $0, " na"}} if not in array, and 3rd column is bigger than 15, print the whole line and append na 

Output:
a, b, 20, ID_100
a2, b2, 8, ID_200
a5, b5, 30, na

In your code, you mismatch and misuse curly braces, the corrected script is:
#!/usr/bin/awk -f
BEGIN {FS=","}
NR==FNR{a[$1$2]=$3;next}
{
    if ($1$2 in a){
      print $0","a[$1$2];
    }else{
      if ($3 > 15){
         print $0",""na";
      }else{
        next
      }
    }
}

