简体   繁体   中英

SAS - using proc imported CSV in proc SQL (error)

I am looking to connect a CSV dataset I imported through 'proc import' with a dataset I am pulling from proc sql. Is there a way to toss my proc import file into proc sql? or vice versa?

here is where I'm at:

proc import datafile = 'filepath'
out = dataname
dbms = CSV
replace
;
run;

proc sql
connect to netezza as dbcon
(server="url" database=sandbox user=me password="&password.");

create table work as

select distinct * from connection to dbcon
(
select distinct a.*

from
dataname as a
left join
sqltable as b
on
a.number = b.number

);
quit;

I am currently receiving this error message but I am unsure where my syntax is wrong:

ERROR: CLI prepare error: ERROR:  relation does not exist database.ADMIN.dataname
SQL statement: select distinct a.*, b.* from dataname as a left join sqltable as b on a.number and b.number.

After you connect to Netezza using the CONNECT TO statement, anything you have inside brackets such as:

select ... from connection to dbcon (...);
exec (...) by dbcon;

Is inside the Netezza box. The dataset you created called dataname is present in the work library where your SAS Session is running.

So the question can be solved in a few ways:

  • Upload data to Netezza
  • Use the libname Netezza engine to connect
  • Create the table in Netezza using Insert into in SAS

Libname engine

You can usually translate a connect to statement into a libname statement as follows:

libname dbcon netezza server="url" database=sandbox user=me password="&password.";

If you create dataname in the dbcon library then your second query should work, provided you have permissions to create tables in the sandbox database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM