BookmarkSubscribeRSS Feed
Patriot1776
Fluorite | Level 6

SAS\Access sqlsvr connecting to Unix MS SQL database containing views with column names exceeding 32 characters in length.  My reading indicates that SAS can overcome the 32 characters restriction by specifying in the LIBNAME statement the PRESERVE_COL_NAMES option.  I've tried =YES as well as =NO and each results in ERROR 65-58: Name '. . . XYZ . . .' is too long for a SAS name in this context.  Any helpful tips to resolve is appreciated.

4 REPLIES 4
Reeza
Super User
You can use SQL Pass through to pull the information OR you can create a view of the tables with a name that's shorter than 32 chars.
LinusH
Tourmaline | Level 20

"This option applies only when you create a new table"

This issue have discussed multiple time on the communities - pls do a search.

In short, you probably need to use explicit SQL pass-thru, or having view created in the RDBMS which complies to SAS naming limits.

Data never sleeps
SASKiwi
PROC Star

You can't have SAS column names longer than 32 characters period. 

 

The only way to reference a longer than 32 character column in SQL Server is by using SAQL PASSTHRU. SAS will truncate the column name to 32 chars when reading it into SAS.

 

proc sql;
  connect to sqlservr (connection string);
  create table test as
  select * from connection to sqlservr
 (select extremely_long_column_name_more_than_32_chars_long
  from tablename
 );
quit; 

 

Patriot1776
Fluorite | Level 6

Thank you all so very much for the rapid responses.  Appreciate it.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 6145 views
  • 0 likes
  • 4 in conversation