BookmarkSubscribeRSS Feed
radha009
Quartz | Level 8

proc sql;
connect to db2 (user='423423' password='fwewerwr' database='sdfsdf' host='fwerwerwe');
create table table_abc (compress=yes) as select* from connection to db2 (
select *
from table2
where status ='A');
quit;

 

-- Executing from SAS 9.4 for windows 

 

ERROR: The DB2 engine cannot be found.
ERROR: A Connection to the db2 DBMS is not currently supported, or is not installed at your
site.

4 REPLIES 4
Krueger
Pyrite | Level 9

Whenever I need to do SQL Pass-Through I use this:

 

PROC SQL;
CONNECT TO odbc ("dsn={name here}");
CREATE TABLE {Table Name} AS
SELECT * FROM connection to odbc
(
SELECT {Column}
FROM Table
);
DISCONNECT FROM odbc;
QUIT;

 

I personally don't have access to use the db2 connection method but I believe you would need to do it like this:

 

proc sql;
connect to db2 (user=_______ database=_______ password=_______);
execute( CREATE TABLE {Table Name} AS
SELECT * FROM connection to odbc
(SELECT {Column}
FROM Table) by db2;
disconnect from db2;
quit;
radha009
Quartz | Level 8
How about username and password to dB connection.
Krueger
Pyrite | Level 9

DSN is something you have pre-configured.

-- This would be at the top of your code
libname rptLib odbc dsn=rpt_Lib_name schema=dbo spool=NO;


--You would then reference it like this.

PROC SQL;
CREATE TABLE Test AS
SELECT *
    FROM rptLib.Table
;QUIT;

If you have this then you can use the first snippet. If not then you'll need to configure the connection with DB2 which would require UserName, Password and Database.

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

you might need to have the DB2 client installed on your work-station

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 1243 views
  • 0 likes
  • 3 in conversation