The test connection is successful in the datasources (ODBC), but when I try uploading the table, it gives me:
ERROR: PROC SQL requires any created table to have at least 1 column.
I don;t understand this error.
proc sql;
connect to odbc (user=xxx password=xxx datasrc=xxx);
create table rwork.xxx_xxx as select * from connection to odbc (
SELECT *
FROM dbo.v_xxx_xxx
WHERE Period_Id=&date_ncr.
);
quit;
What do you mean by uploading the table? Does the SAS LIBREF RWORK refer to a SAS library or a non-SAS datasource?
If you run the following test does it give you at least one data column?
proc sql outobs = 10;
connect to odbc (user=xxx password=xxx datasrc=xxx);
select * from connection to odbc (
SELECT *
FROM dbo.v_xxx_xxx
WHERE Period_Id=&date_ncr.
);
quit;
SAS Kiwi,
we reach into a databse to pull in table dbo.v_xxx_xxx into a SAS dataset (this is what I meant by uploading). The SAS dataset we are creating from the dbo.v_xxx_xxx view will reside in a UNIX environement which is referenced by rwork. RWORK is defined and has always been working without any issues.
as for the sample you asked me to run (adding outobs=10), it provided me with the same error.
Thanks.
Whenever there is doubt about the data source, and you ave an explicit SQL - just try that SQL in the data source, using the same userid used in the connect to statement.
Please note my sample used select * not create table to try to avoid your error. Did you still get the same error?
It is possible to replicate this error for example:
Libname sqlstage ODBC Schema=DBO DSN=sqlstage;
Proc SQL;
*Drop Table sqlstage.Test_x_3;
Create Table sqlstage.Test_x_3 (Var Float);
Create Table sqlstage.Test_x_4 As Select * From sqlstage.Test_x_3 (Drop=Var);
Quit;
Gives:
ERROR: Table SQLSTAGE.Test_x_3 doesn't have any columns. PROC SQL requires each of its tables to have at least 1 column.
Could it be that there actually are no columns or that the user simply hasn't the permission to access this table?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.