BookmarkSubscribeRSS Feed
jmoore168
Obsidian | Level 7

I'm trying to making a connection to an ODBC server however I'm getting this error message:

 

ERROR: CLI error trying to establish connection: [unixODBC][Driver Manager]Data source name not found, and no default driver
specified
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
687 create table test1 as select * from connection to ODBC (
688 select
689 a.*
690 FROM rptingdata.roactreacc a
691 FETCH FIRST 20 ROWS ONLY
692
693 ) ;
NOTE: Statement not executed due to NOEXEC option.
694 disconnect from ODBC;
NOTE: Statement not executed due to NOEXEC option.
695 quit;
NOTE: The SAS System stopped processing this step because of errors.

 

Here's my code:

 

 

 

proc sql;
CONNECT TO ODBC (DSN=SERVER user=U212XXXX password = XXXXXXX );
create table test1 as select * from connection to ODBC (
select
a.*
FROM rptingdata.roactreacc a
FETCH FIRST 20 ROWS ONLY

) ;
disconnect from ODBC;
quit;

Any help would be appreciated!

 

 

2 REPLIES 2
Reeza
Super User
What happens if you try a libname connection instead of doing SQL Pass Through?
SASKiwi
PROC Star

The error message is telling you there is no data source called SERVER defined in your odbc.ini (since you are on Unix) nor do you have a default ODBC driver defined. These need to be added before your connection will work.

 

Alternatively you could try defining everything in the connection string which will look similar to this:

proc sql;
 connect to odbc (noprompt = "server=MyServerName;DRIVER=SQL Server;uid=myusr1;pwd=mypwd1;");
  create table Want  as 
  select * from connection to odbc
  (SELECT *
   FROM [MyDatabase].[MySchema1].[MyTable]
   )
  ;
  disconnect from odbc;
quit;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 388 views
  • 2 likes
  • 3 in conversation