<?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 How to remove leading zeros from character varibale and convert to numeric in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287057#M58999</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt; I Have a character variable with comes with leading zeroes&amp;nbsp;and&amp;nbsp;my desired result should be numeric with removal of leading zeros&lt;/P&gt;
&lt;P&gt;and substr the values from 3rd position&amp;nbsp; BID= Substr(AID,3,3) &lt;BR /&gt;&lt;BR /&gt; AID&lt;BR /&gt;&amp;nbsp;00000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;000001&lt;/P&gt;
&lt;P&gt;&amp;nbsp;000011&lt;/P&gt;
&lt;P&gt;000100&lt;/P&gt;
&lt;P&gt;I20800&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; my desired result:&lt;BR /&gt; BID&lt;BR /&gt;&amp;nbsp;0&lt;BR /&gt;&amp;nbsp;1&lt;/P&gt;
&lt;P&gt;11&lt;/P&gt;
&lt;P&gt;100&lt;/P&gt;
&lt;P&gt;800&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone pls help&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jul 2016 01:33:10 GMT</pubDate>
    <dc:creator>chennupriya</dc:creator>
    <dc:date>2016-07-26T01:33:10Z</dc:date>
    <item>
      <title>How to remove leading zeros from character varibale and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287057#M58999</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt; I Have a character variable with comes with leading zeroes&amp;nbsp;and&amp;nbsp;my desired result should be numeric with removal of leading zeros&lt;/P&gt;
&lt;P&gt;and substr the values from 3rd position&amp;nbsp; BID= Substr(AID,3,3) &lt;BR /&gt;&lt;BR /&gt; AID&lt;BR /&gt;&amp;nbsp;00000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;000001&lt;/P&gt;
&lt;P&gt;&amp;nbsp;000011&lt;/P&gt;
&lt;P&gt;000100&lt;/P&gt;
&lt;P&gt;I20800&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; my desired result:&lt;BR /&gt; BID&lt;BR /&gt;&amp;nbsp;0&lt;BR /&gt;&amp;nbsp;1&lt;/P&gt;
&lt;P&gt;11&lt;/P&gt;
&lt;P&gt;100&lt;/P&gt;
&lt;P&gt;800&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone pls help&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 01:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287057#M58999</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2016-07-26T01:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove leading zeros from character varibale and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287065#M59002</link>
      <description>&lt;P&gt;Input ignoring the leading zeroes issue. SAS will remove them automatically.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 02:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287065#M59002</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-07-26T02:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove leading zeros from character varibale and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287066#M59003</link>
      <description>&lt;P&gt;But what function should i need to use to get BID from AID&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 02:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287066#M59003</guid>
      <dc:creator>chennupriya</dc:creator>
      <dc:date>2016-07-26T02:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove leading zeros from character varibale and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287070#M59007</link>
      <description>&lt;P&gt;The INPUT() function can convert a character string to a new value by applying the INFORMAT that you choose.&lt;/P&gt;
&lt;P&gt;But you will need to explain why you want to convert the last string into the number 800. Why did you ignore the letter 'I' at the beginning of the string? &amp;nbsp;Why not 20,800 instead of 800?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input AID $char12. ;
cards;
 00000
 000001
 000011
000100
I20800
;

data want ;
 set have ;
 bid = input(aid,12.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 02:20:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287070#M59007</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-07-26T02:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove leading zeros from character varibale and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287072#M59009</link>
      <description>&lt;P&gt;With regular expression processing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length BID $8;
BID = prxchange("s/..0*(\S+)/\1/o", 1, AID);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jul 2016 02:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287072#M59009</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-07-26T02:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove leading zeros from character varibale and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287087#M59014</link>
      <description>&lt;P&gt;BID= input(substr(AID,3,3) ,32.);&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 04:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287087#M59014</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-07-26T04:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove leading zeros from character varibale and convert to numeric</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287115#M59023</link>
      <description>&lt;P&gt;You should really use the {i} symbol to post data, as this uses a fixed-width font and preserves correct spacing. As it is, your example data does not match your stated requirements.&lt;/P&gt;
&lt;P&gt;Per your requirements,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
bid = input(substr(aid,4,3),3.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;should do the trick.&lt;/P&gt;
&lt;P&gt;(getting the last 3 characters from a 6-character string requires starting at position 4)&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jul 2016 07:56:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-remove-leading-zeros-from-character-varibale-and-convert/m-p/287115#M59023</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-07-26T07:56:43Z</dc:date>
    </item>
  </channel>
</rss>

