<?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: function to change character strings into acceptable variable name format? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714128#M220416</link>
    <description>&lt;P&gt;You can always do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;str_ = prxchange("s/[[:^alnum:]]/_/o", -1, strip(str));&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Jan 2021 23:35:10 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2021-01-25T23:35:10Z</dc:date>
    <item>
      <title>function to change character strings into acceptable variable name format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714089#M220402</link>
      <description>&lt;P&gt;Is there a function to replace all characters that are not letters, numbers or underscores,&amp;nbsp; to an underscore?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am nearly certain i've run across one before, and used it.&amp;nbsp; But I have been unable to find it again.&lt;/P&gt;
&lt;P&gt;I recall the function having at least 3 arguments, one of them being modifiers, allowing you to select all letters and numbers to the list of acceptable characters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought it was TranWrd but that does not have a modifiers argument.&amp;nbsp; Same with Translate.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 21:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714089#M220402</guid>
      <dc:creator>mcook</dc:creator>
      <dc:date>2021-01-25T21:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: function to change character strings into acceptable variable name format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714101#M220407</link>
      <description>&lt;P&gt;If you are getting such characters in variable names then it has something with how you are reading the data and I strongly suspect Proc Import.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very simple to prevent: Options validvarname=V7;&lt;/P&gt;
&lt;P&gt;prior to proc import.&lt;/P&gt;
&lt;P&gt;That will force Proc import to create variable names compatible with the SAS version 7, i.e. no characters other than letters, digits and _.&lt;/P&gt;
&lt;P&gt;Much easier to prevent than to correct later.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 22:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714101#M220407</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-25T22:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: function to change character strings into acceptable variable name format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714108#M220410</link>
      <description>&lt;P&gt;NLITERAL function?&lt;/P&gt;
&lt;P&gt;NVALID function may also be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;COMPRESS() is the only function I can think that comes close to what you've described but I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;that changing how you import your data is a better overall solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 22:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714108#M220410</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-01-25T22:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: function to change character strings into acceptable variable name format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714128#M220416</link>
      <description>&lt;P&gt;You can always do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;str_ = prxchange("s/[[:^alnum:]]/_/o", -1, strip(str));&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 23:35:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714128#M220416</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2021-01-25T23:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: function to change character strings into acceptable variable name format?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714219#M220472</link>
      <description>str_ = prxchange("s/\W/_/o", -1, strip(str));</description>
      <pubDate>Tue, 26 Jan 2021 11:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/function-to-change-character-strings-into-acceptable-variable/m-p/714219#M220472</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-01-26T11:23:15Z</dc:date>
    </item>
  </channel>
</rss>

