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

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1470 views
  • 0 likes
  • 3 in conversation