<?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: Remove leading zeros in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879998#M347658</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input str $12.;
cards;
00099V67
000123
12345
;

data want;
  set have;
  want=prxchange('s/^0+//',1,strip(str));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 10 Jun 2023 09:10:00 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-06-10T09:10:00Z</dc:date>
    <item>
      <title>Remove leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879966#M347634</link>
      <description>How do i remove leading zeros for a variable with values that look like this:&lt;BR /&gt;&lt;BR /&gt;00099V67&lt;BR /&gt;000123&lt;BR /&gt;&lt;BR /&gt;Some have two zeros in front some have three. &lt;BR /&gt;</description>
      <pubDate>Fri, 09 Jun 2023 20:18:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879966#M347634</guid>
      <dc:creator>bhca60</dc:creator>
      <dc:date>2023-06-09T20:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: Remove leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879969#M347637</link>
      <description>&lt;P&gt;You apparently have a character variable, since one of your sample values has the letter "V" in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, and definitely foremost:&amp;nbsp; &lt;EM&gt;&lt;STRONG&gt;why do you want to remove leading zeroes from a non-numeric variable?&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say you did so.&amp;nbsp; Then, since your sort order is lexicographic, instead of sort order of&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;000999&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;002231&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;011577&lt;/STRONG&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with leading zeroes removed (and the remaining characters left-justified) you would have this order:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;11577&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;2231&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT face="courier new,courier"&gt;999&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you really want that&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879969#M347637</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-06-09T22:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Remove leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879974#M347640</link>
      <description>&lt;P&gt;This has been asked before, you could search and see if you can find the older discussions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what the VERIFY function is good at.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input str $12.;
cards;
00099V67
000123
12345
;

data want;
  set have;
  if verify(trim(str),'0') then str=substr(str,verify(str,'0'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 21:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879974#M347640</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-06-09T21:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: Remove leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879979#M347644</link>
      <description>&lt;P&gt;What does your variable represent? Leading zeroes can have meaning in character variables and could be dangerous to remove.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:45:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879979#M347644</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2023-06-09T22:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Remove leading zeros</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879998#M347658</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input str $12.;
cards;
00099V67
000123
12345
;

data want;
  set have;
  want=prxchange('s/^0+//',1,strip(str));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 10 Jun 2023 09:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-leading-zeros/m-p/879998#M347658</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-06-10T09:10:00Z</dc:date>
    </item>
  </channel>
</rss>

