PROC DS2 code returns a "Table does not exist or cannot be accessed" error when you query a database table


When you are using the DS2 procedure, if SCHEMA= is defined in the LIBNAME statement, it is not passed to the database when you query the table. You receive errors similar to this:

ERROR: Table "libref.table-name" does not exist or cannot be accessed
ERROR: Unable to prepare SELECT statement for table table-name.

Change your PROC DS2 code to a three-level name:

"libref.schema.table-name"

Sample Code

libname mylib ODBC dsn=datasource-name user=user-ID password=password schema=dbo;
 
proc ds2;
   data work.demo_ds2;
   method run();
     set mylib.dbo.abcdefg;
   end;
   enddata;
   run;
quit;