<?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: PROC SQL: Remove initial zeros from an alphanumeric field in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846549#M334641</link>
    <description>&lt;P&gt;Thanks for your answer, but &lt;EM&gt;cod_acometida&lt;/EM&gt; has many rows, not just the few ones that I put as an example. I'm trying to handle it as a SQL query within a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Actually I need to use that&amp;nbsp;&lt;EM&gt;cod_acometida&lt;/EM&gt; (but 'zeroless') in a JOIN clause; it appears without zeros in the other table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 08:17:39 GMT</pubDate>
    <dc:creator>JavierBlanco</dc:creator>
    <dc:date>2022-11-28T08:17:39Z</dc:date>
    <item>
      <title>PROC SQL: Remove initial zeros from an alphanumeric field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846547#M334639</link>
      <description>&lt;P&gt;I need to remove some initial zeros from a field (it appears as an alphanumeric one in the DB) like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;cod_acometida
000000000003391901
000000000008271401
000000000007696901
000000000005504701
000000000002298401
000000000000332701
000000000013942801&lt;BR /&gt;etc.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's a variable number of characters but they are always zeros at the beginning of the string. I'm new at SAS, not sure if RegEx is applicable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using Enterprise Guide 7.15.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 08:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846547#M334639</guid>
      <dc:creator>JavierBlanco</dc:creator>
      <dc:date>2022-11-28T08:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Remove initial zeros from an alphanumeric field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846548#M334640</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input cod_acometida :$20.;
datalines;
000000000003391901
000000000008271401
000000000007696901
000000000005504701
000000000002298401
000000000000332701
000000000013942801
;

data want;
   set have;
   cod_acometida = substr(cod_acometida, verify(cod_acometida, '0'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Nov 2022 08:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846548#M334640</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-28T08:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Remove initial zeros from an alphanumeric field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846549#M334641</link>
      <description>&lt;P&gt;Thanks for your answer, but &lt;EM&gt;cod_acometida&lt;/EM&gt; has many rows, not just the few ones that I put as an example. I'm trying to handle it as a SQL query within a&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;PROC SQL;&lt;/P&gt;&lt;P&gt;***&lt;/P&gt;&lt;P&gt;QUIT;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Actually I need to use that&amp;nbsp;&lt;EM&gt;cod_acometida&lt;/EM&gt; (but 'zeroless') in a JOIN clause; it appears without zeros in the other table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 08:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846549#M334641</guid>
      <dc:creator>JavierBlanco</dc:creator>
      <dc:date>2022-11-28T08:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Remove initial zeros from an alphanumeric field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846552#M334642</link>
      <description>&lt;P&gt;You can use the exact same expression in a Proc SQL Step. If you want to use the value without zeros in a join, simply use the&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;substr(cod_acometida, verify(cod_acometida, '0'))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;part directly in the join.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 08:33:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846552#M334642</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-28T08:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Remove initial zeros from an alphanumeric field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846553#M334643</link>
      <description>&lt;P&gt;The DATA step with DATALINES is just there to make&amp;nbsp;&lt;U&gt;usable example data&lt;/U&gt;&amp;nbsp;(please remember this term and method, and use it to present example data in your future questions) out of the text you posted. It is not needed for your real data, which should already be in a SAS dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before you attempt the join, make sure that the variable types match, and see if you have leading blanks in the "other" dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 09:18:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846553#M334643</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-28T09:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Remove initial zeros from an alphanumeric field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846554#M334644</link>
      <description>&lt;P&gt;PS another method to get rid of the zeroes is a short departure into numeric:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cod_acometida = put(input(cod_acometida,32.),32. -l);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Nov 2022 09:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846554#M334644</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-28T09:22:36Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL: Remove initial zeros from an alphanumeric field</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846559#M334648</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;The method suggested&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;cod_acometida = put(input(cod_acometida,32.),32. -l);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will work for the data shown, but if the string has more than 15 significant digits (it is, after all, 19 digits long) you may get rounding errors.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 10:11:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-Remove-initial-zeros-from-an-alphanumeric-field/m-p/846559#M334648</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2022-11-28T10:11:25Z</dc:date>
    </item>
  </channel>
</rss>

