<?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: Convert &amp;quot;SQL&amp;quot; style name (hyphens, etc) to SAS? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204615#M4571</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case this is of any help, the code sample below will translate all sorts of characters which are not valid for a SAS Name into an underscore. Beside that I would recommend Proc DATASETS with the RENAME statement, this way you avoid reading the again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; test;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;truncover&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$50.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; name2 = name; &lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; find(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"0123456789"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, char(name2, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;do&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; substr(name2,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"_"&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;end&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; name2 = basechar(name2);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; name2 = prxchange(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"s/[^a-z¦A-Z¦0-9¦_]/_/"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, -&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, strip(name2));&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards4&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;übergang&lt;BR /&gt;valid_name&lt;BR /&gt;lt-acnt&lt;BR /&gt;1 year&lt;BR /&gt;some name&lt;BR /&gt;a.id&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Apr 2015 16:17:03 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2015-04-27T16:17:03Z</dc:date>
    <item>
      <title>Convert "SQL" style name (hyphens, etc) to SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204611#M4567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My input data has things like spaces and dashes in a SQL table, is there a quick way to convert to SAS names, rather than doing the whole thing like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a."lt-acnt"n as lt_acnt,&lt;/P&gt;&lt;P&gt;a."new-mtg-nbr"n as new_mtg_nbr,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;etc?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 14:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204611#M4567</guid>
      <dc:creator>wcp_fnfg</dc:creator>
      <dc:date>2015-04-27T14:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert "SQL" style name (hyphens, etc) to SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204612#M4568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, the options validavarname=any; will allow you to work with these:&lt;/P&gt;&lt;P&gt;options validvarname=any;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; "lt-acnt"n="abc"; output;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can then easily post-process the metadata something like:&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.vcolumn (where=(libname="WORK" and memname="HAVE")) end=last;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then call execute('data want; set have (rename=(');&lt;/P&gt;&lt;P&gt;&amp;nbsp; call execute("'"||strip(name)||"'n="||strip(tranwrd(name,"-","_")));&lt;/P&gt;&lt;P&gt;&amp;nbsp; if last then call execute('));run;');&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204612#M4568</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-04-27T15:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Convert "SQL" style name (hyphens, etc) to SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204613#M4569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How where the original SAS Data Sets created? Using the Import task from EG or Proc Import or ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are using SAS Enterprise Guide, it will set the SAS System Option VALIDVARNAME=ANY. This might be the cause of the names you are seeing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;options&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;validvarname&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=v7; so that Proc IMPORT creates names with underscores at places where the original name had blanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204613#M4569</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-04-27T15:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Convert "SQL" style name (hyphens, etc) to SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204614#M4570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's a decent idea, using the dictionary tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't create the data, so using vvn=v7 to convert on the input is not an option.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 15:23:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204614#M4570</guid>
      <dc:creator>wcp_fnfg</dc:creator>
      <dc:date>2015-04-27T15:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Convert "SQL" style name (hyphens, etc) to SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204615#M4571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case this is of any help, the code sample below will translate all sorts of characters which are not valid for a SAS Name into an underscore. Beside that I would recommend Proc DATASETS with the RENAME statement, this way you avoid reading the again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; test;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;infile&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;truncover&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;$50.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; ;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp; name2 = name; &lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; find(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"0123456789"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, char(name2, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;)) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;do&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; substr(name2,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;) = &lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"_"&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;end&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp; name2 = basechar(name2);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; name2 = prxchange(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;"s/[^a-z¦A-Z¦0-9¦_]/_/"&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, -&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;, strip(name2));&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;cards4&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;übergang&lt;BR /&gt;valid_name&lt;BR /&gt;lt-acnt&lt;BR /&gt;1 year&lt;BR /&gt;some name&lt;BR /&gt;a.id&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2015 16:17:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Convert-quot-SQL-quot-style-name-hyphens-etc-to-SAS/m-p/204615#M4571</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-04-27T16:17:03Z</dc:date>
    </item>
  </channel>
</rss>

