<?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: questions on two string functions in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326466#M72691</link>
    <description>Thank you very much, both of you!</description>
    <pubDate>Sat, 21 Jan 2017 03:09:57 GMT</pubDate>
    <dc:creator>fengyuwuzu</dc:creator>
    <dc:date>2017-01-21T03:09:57Z</dc:date>
    <item>
      <title>questions on two string functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326436#M72679</link>
      <description>&lt;P&gt;I encounter two interesting functions today and want to find out what they do:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) I found it &lt;A href="https://communities.sas.com/t5/SAS-Procedures/How-to-remove-leading-zeroes-from-character-variable/td-p/51703?nobounce" target="_self"&gt;here&lt;/A&gt; : This can remove leading 0s from a string. But what does "+//o" do in y =prxchange('s/^0+//o',-1,x)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data val;
x='000asd1234';output;
x='123'; output;
x='0009876'; output;
run;

data nozero;
   set val;
   y =prxchange('s/^0+//o',-1,x);
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I wanted to remove leading dashes, and it works by replacing 0 to -, but I still do not understand it well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data val;
x='-000asd1234';output;
x='1-23'; output;
x='0009-876'; output;
run;

data nozero;
   set val;
   y =prxchange('s/^-+//o',-1,x);
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;2. Another function if anyalpha:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if anyalpha(string) then string='';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;anyalpha(string) will return 0 if there is no alphabeta found, or first position of an alphabeta character. In the above code, does&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if anyalpha(string) &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is the same as&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if anyalpha(string) &amp;gt;0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;? i.e. if string contains any alphabeta characters, then set it to missing?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 22:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326436#M72679</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-01-20T22:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: questions on two string functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326444#M72681</link>
      <description>&lt;P&gt;For details on search and replacement with the PRX functions do a search on " PERL Regular expressions". This is a tool ported into SAS from other environments and there is lots of documentation and examples around.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second part is how SAS treats numeric values when used as a boolean. Any missing or 0 value is considered "false", anything else is true.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;See this code for simple example:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   input x;
   if x then put x= +1 "x is true";
   else put x= +1 "x is false";
datalines;
1
0
.
-5
34.577
;
run;&lt;/PRE&gt;
&lt;P&gt;So when the result of any function is &amp;gt; 0 then it can be used as "TRUE".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 23:00:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326444#M72681</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-20T23:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: questions on two string functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326446#M72682</link>
      <description>&lt;P&gt;'s/^0+//o' reads:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;s/&amp;lt;1&amp;gt;/&amp;lt;2&amp;gt;/ : substitute a substring matching the pattern &amp;lt;1&amp;gt; by pattern &amp;lt;2&amp;gt;&lt;/P&gt;
&lt;P&gt;^ : match the string beginning&lt;/P&gt;
&lt;P&gt;0+ : match the character '0' one or more times&lt;/P&gt;
&lt;P&gt;o : suffix requesting that the pattern be compiled only once instead of on every function call&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so the prxChange operation substitutes a succession of one or more '0's at the beginning of the string with nothing.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 23:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326446#M72682</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-01-20T23:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: questions on two string functions</title>
      <link>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326466#M72691</link>
      <description>Thank you very much, both of you!</description>
      <pubDate>Sat, 21 Jan 2017 03:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/questions-on-two-string-functions/m-p/326466#M72691</guid>
      <dc:creator>fengyuwuzu</dc:creator>
      <dc:date>2017-01-21T03:09:57Z</dc:date>
    </item>
  </channel>
</rss>

