I don't know if the log will be useful. I'm using SAS as a pass through. I've tried running your solution separate of the connection to our database and it works in a 2 step process where I extract just the 4 variables and then separately run the proc sql solution you gave above. Here's my code, based on your help. proc sql; connect to XXXX as IQ (user = XXX password = XXX host='XXX' database='XXX' server='XXX' port='XXX'); create table Plan_home_details as select * from connection to IQ ( select p.pol_no, p.tx_pol_ver_dt, min(p.plan_typ) as min_plan_type, p.plan_desc from FDSS_ANA2.pla_pol p where p.pol_no = 123456789 /*I'm testing on a single policy number*/ and p.pol_tx_typ in (3,4,5) group by p.pol_no, p.tx_pol_ver_dt having p.plan_typ=calculated min_plan_type ); disconnect from IQ; quit; The log says the following: ERROR: CLI prepare error: [Sybase][ODBC Driver][Sybase IQ]Syntax error near 'min_plan_type' on line 1
... View more