1
votes

SAS has a 32 character limit for table- and column-names. I have a scenario where I want to select from Table A and join with Table B (where Table B has a name above 32 characters). If I try to write this in PROC SQL, I get an error saying that Table B has a name exceeding 32 characters.

Anyone know how I can get arround this?

3

3 Answers

2
votes

Assuming this is working with a non-SAS DBMS, like SQL Server, you should use passthrough SQL to process the select, as this works with the RDBMS's syntax and doesn't have the 32 character limitation.

IE:

proc sql;
  connect to oledb (... init string ... );
  create table work.mydata as 
    select * from connection to oledb (
      ... sql server or whatever syntax ...
    );
quit;

You also could ask the DBA to construct a view that had a < 32 character long name.

0
votes

It is illegal for a SAS table to have more than 32 characters, you will have to rename the physical file. If you are reading a database table, you can do so using SQL passthrough like this:

proc sql; 
connect to odbc(dsn=mydsn user=xxxx pwd=yyy); 
select * from connection to odbc 
(select * from my_table_with_a_very_Very_Very_Long_name); 
disconnect from odbc; 
quit;
-1
votes

SAS can't work with a "table" with that long name. You'll have to rename the file.