ERROR: Read Access Violation when missing an equal sign on WHERE clause with MERGE statement


When the equal sign is missing on the WHERE data set option with the MERGE statement, a Read Access Violation DATASTEP ERROR message occurs in the SAS log. Also, there are lot of unrecognizable characters followed by the correct ERROR message in the SAS log. The correct ERROR message is:

ERROR 12-63: Missing '=' for option WHERE.

Here is an example of INCORRECT syntax that generates the above ERROR messages:

data both;                                                                   
     merge one(in=in1 where(substr(id,1,2) in ('11','22','88'))) 
     two(in=in2);                                               
     by id;                                                                       
     if in1 and in2 then output both;                                           
run;

By adding the missing equal sign after the WHERE data set option, the ERROR will be eliminated. Here is the correct syntax:

data both;                                                                   
     merge one(in=in1 where=(substr(id,1,2) in ('11','22','88'))) 
     two(in=in2);                                               
     by id;                                                                       
     if in1 and in2 then output both;                                           
run;