<?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: Restrict sas dataset column name to max 30 characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296254#M270253</link>
    <description>&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
/* Limit name length to 5 chars */
select catx(" as ",name,substr(name,1,5)) 
into :cols separated by ","
from dictionary.columns
where libname="SASHELP" and memname="CLASS"; /* use uppercase */
create table myClass as
select &amp;amp;cols.
from sashelp.class;
describe table myClass;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Sep 2016 22:29:24 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-09-02T22:29:24Z</dc:date>
    <item>
      <title>Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296211#M270252</link>
      <description>&lt;P&gt;I am creating a sas dataset using excel table I am following this below approach since I am able to import .xlsm extension excel files using this approach only. This works fine but I want to reduce some manual for renaming column names before uploading into teradata. i.e. SAS dataset max column name length is 32 but teradata is 30 characters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if there are any ways to restrict all sas dataset columns max length to 30 characters. There are more than 50 columns so I dont want go one by one column formatting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;libname xlsFile XLSX /path/filename;
options validvarname=v7;

PROC SQL;
    create table work.sample as 
	(select * from xlsFile.sheet1);
 quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Sep 2016 19:22:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296211#M270252</guid>
      <dc:creator>jayakumarmm</dc:creator>
      <dc:date>2016-09-02T19:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296254#M270253</link>
      <description>&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
/* Limit name length to 5 chars */
select catx(" as ",name,substr(name,1,5)) 
into :cols separated by ","
from dictionary.columns
where libname="SASHELP" and memname="CLASS"; /* use uppercase */
create table myClass as
select &amp;amp;cols.
from sashelp.class;
describe table myClass;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Sep 2016 22:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296254#M270253</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-02T22:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296261#M270254</link>
      <description>&lt;P&gt;Truncating variable names may lead to duplicate names ?!&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; having variables names, for example: &amp;nbsp;variable1 , variable2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; then truncatin them by substring(1,5) will result in: varia , varia&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; that means duplicate names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At least need check and give warning.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I wrong ?&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2016 00:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296261#M270254</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-09-03T00:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296266#M270255</link>
      <description>&lt;P&gt;Proc SQL will give you a warning if you try to create&amp;nbsp;a duplicate name.&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2016 01:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296266#M270255</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-03T01:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296323#M270256</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Proc SQL will give you a warning if you try to create&amp;nbsp;a duplicate name.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Consequence: Don't rename columns automatically, always use a mapping table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2016 20:36:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296323#M270256</guid>
      <dc:creator>error_prone</dc:creator>
      <dc:date>2016-09-03T20:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296326#M270257</link>
      <description>&lt;P&gt;I have built a macro to rename any dataset variable names&lt;/P&gt;&lt;P&gt;that can be addapted to any desired transformation - (line 15 in attached progran, define &lt;STRONG&gt;a_line&lt;/STRONG&gt; contents).&lt;/P&gt;&lt;P&gt;For debuging I have renamed variables to v1 ... vn, but can be changed to :&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; a_line&lt;/STRONG&gt; = compbl( var || '=substr(' || var || ',1,30);') ; &amp;nbsp;&lt;/P&gt;&lt;P&gt;or in order to eliminate posibility of duplicate names&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; a_line&lt;/STRONG&gt; = compbl(var || &lt;SPAN&gt;'=substr(' || var || ',1,27)' || left(i)) ;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Sep 2016 21:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296326#M270257</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-09-03T21:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296340#M270258</link>
      <description>&lt;P&gt;Thank you for your great solution but I am getting below error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;+_COLUMN1 =substr(_COLUMN1,1,27)1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; _&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;22&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, ;.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 00:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296340#M270258</guid>
      <dc:creator>jayakumarmm</dc:creator>
      <dc:date>2016-09-04T00:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Restrict sas dataset column name to max 30 characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296355#M270259</link>
      <description>&lt;P&gt;I need your code or full log to understand what caused the error&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 04:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Restrict-sas-dataset-column-name-to-max-30-characters/m-p/296355#M270259</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-09-04T04:53:49Z</dc:date>
    </item>
  </channel>
</rss>

