<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Truncation of DBMS column names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439752#M282426</link>
    <description>&lt;P&gt;Thank you so much to all of you! A combination of all of your responses got me what I needed. it is so crazy that this is such a problem. smh&lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2018 16:30:52 GMT</pubDate>
    <dc:creator>LOLO</dc:creator>
    <dc:date>2018-02-23T16:30:52Z</dc:date>
    <item>
      <title>Truncation of DBMS column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439477#M282422</link>
      <description>&lt;P&gt;I know this is an issue that comes up over and over and I've been reading posts about it all day trying to figure this out. I inherited a program that used to use an SQL pass through method to load data. This is no longer available to me and so now we are connecting to the SQL server more directly but it is causing a problem with the truncation of the column names. There are many tables and many variables and sometimes there will be several variables that all exceed 32 characters but that have the same 32 characters to begin with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example:&lt;/P&gt;
&lt;P&gt;var1=abcdefghijklmnopqrstuvwxyzaaaaaabb&lt;/P&gt;
&lt;P&gt;var2=abcdefghijklmnopqrstuvwxyzaaaaaacc&lt;/P&gt;
&lt;P&gt;var3=abcdefghijklmnopqrstuvwxyzaaaaaadd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So what happens right now is that var1 gets truncated to abcdefghijklmnopqrstuvwxyzaaaaaa and var2 and var3 are dropped.&lt;/P&gt;
&lt;P&gt;What I want:&lt;/P&gt;
&lt;P&gt;var1=abcdefghijklmnopqrstuvwxyzaaaaa1&lt;/P&gt;
&lt;P&gt;var2=abcdefghijklmnopqrstuvwxyzaaaaa2&lt;/P&gt;
&lt;P&gt;var3=abcdefghijklmnopqrstuvwxyzaaaaa3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My simplified code looks something like this:&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Libname&amp;nbsp;test odbc dsn=dataset schema=xx preserve_col_names=yes;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Proc sql ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Create table xxx select&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT face="Calibri"&gt;&lt;FONT size="3"&gt;&lt;FONT color="#000000"&gt;x.* &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;from yyy;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;Does anyone know of any option that tells SAS to go ahead and truncate but add numeric suffixes to variables with the same first 32 characters?? &lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;THANK YOU!!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 21:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439477#M282422</guid>
      <dc:creator>LOLO</dc:creator>
      <dc:date>2018-02-22T21:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of DBMS column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439559#M282423</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I don't have a db to test on at the moment but on your libname statement you can add the following two options;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;preserve_col_names=yes&lt;/LI&gt;&lt;LI&gt;perserve_tab_names=yes&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;There is also a SAS option for exceeding the 32 character restriction.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;options validmemname=EXTEND;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Passthrough SQL lets you reference the DB column names and I believe FedSQL and DS2 also accepts DB names however I don't think I've had an opportunity to test it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 01:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439559#M282423</guid>
      <dc:creator>foobarbaz</dc:creator>
      <dc:date>2018-02-23T01:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of DBMS column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439560#M282424</link>
      <description>&lt;P&gt;Sadly this is an old issue and SAS seem to be sitting on their hands regarding SQL server names. See &lt;A href="https://communities.sas.com/t5/SASware-Ballot-Ideas/Metadata-amp-colon-More-space-please/idi-p/220310" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The full variable name is normally stored as the variable label, but in your case some variables are dropped.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't think of a good reason why some variables are dropped when the 32 first characters of the name are identical.&lt;/P&gt;
&lt;P&gt;The renaming logic (with suffix numbers) you are suggesting is much more sensible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is plainly an oversight, like "no one will ever make&amp;nbsp;&lt;SPAN&gt;the 32 first characters of variables identical" to paraphrase an infamous&amp;nbsp;line.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Are you sure you can't submit pass-through code? What happens when you run:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Calibri" size="3" color="#000000"&gt;libname TEST odbc dsn=dataset schema=xx preserve_col_names=yes;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Calibri" size="3" color="#000000"&gt;proc sql ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Calibri" size="3" color="#000000"&gt;&amp;nbsp; connect using TEST;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Calibri" size="3" color="#000000"&gt;&amp;nbsp; select * from connection to TEST ( select&amp;nbsp;&lt;SPAN&gt;abcdefghijklmnopqrstuvwxyzaaaaaabb as VAR1 from YYY);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Calibri" size="3" color="#000000"&gt;quit;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If no pass-through code is possible, the only solution I can think of, since DBAs will probably not change the column names, is that a SQL server view is created for you with new names.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 01:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439560#M282424</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2018-02-23T01:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of DBMS column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439578#M282425</link>
      <description>&lt;P&gt;SAS does not make this easy.&lt;/P&gt;
&lt;P&gt;Are you sure that the passthru method is no longer available to you?&lt;/P&gt;
&lt;P&gt;If you have a libref defined to connect to the database you can use it with PROC SQL.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname xdb .... ;
proc sql ;
connect using xdb ;
create table work.sasds as
select
  var1 label='INeverLearnedHowToEditMyPapersInEnglishClass'
 ,var2 label='INeverLearnedHowToEditMyPapersInJournalismClass'
 ,var3 label='INeverLearnedHowToEditMyPapersInComputerScienceClass'
from connection to xdb (
select
   INeverLearnedHowToEditMyPapersInEnglishClass var1
  ,INeverLearnedHowToEditMyPapersInJournalismClass var2
  ,INeverLearnedHowToEditMyPapersInComputerScienceClass var3
from sometable
);
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Feb 2018 03:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439578#M282425</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-02-23T03:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Truncation of DBMS column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439752#M282426</link>
      <description>&lt;P&gt;Thank you so much to all of you! A combination of all of your responses got me what I needed. it is so crazy that this is such a problem. smh&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 16:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Truncation-of-DBMS-column-names/m-p/439752#M282426</guid>
      <dc:creator>LOLO</dc:creator>
      <dc:date>2018-02-23T16:30:52Z</dc:date>
    </item>
  </channel>
</rss>

