<?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: How to add leading zero in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406119#M279267</link>
    <description>&lt;P&gt;Are you reading data or exporting data? And when exporting, make sure you look at the text file, not the csv in Excel. Excel will strip leading zeros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post your code as well please with an example of the issue.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Oct 2017 19:57:34 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-10-20T19:57:34Z</dc:date>
    <item>
      <title>How to add leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406114#M279266</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to read data from a csv file and want to add the leading zero to the values w. fewer than three digits (character) For instance, 95 should be 095, 14 should be 014, 215 should be 215 etc. I tried formatting the column w. custom (000) , however when I tried saving the csv file it didn't get saved. Can someone help me how to do this in SAS?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 19:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406114#M279266</guid>
      <dc:creator>Kiko</dc:creator>
      <dc:date>2017-10-20T19:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to add leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406119#M279267</link>
      <description>&lt;P&gt;Are you reading data or exporting data? And when exporting, make sure you look at the text file, not the csv in Excel. Excel will strip leading zeros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Post your code as well please with an example of the issue.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 19:57:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406119#M279267</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-20T19:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to add leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406137#M279268</link>
      <description>&lt;P&gt;Thank you for your reply. I am trying to read data (csv.) into SAS. I want to create a few age-related variables using the existing age variable (tAge is the existing age variable)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;New_Age=input(substr (tAge, 2,2),2.);&amp;nbsp;&lt;/P&gt;&lt;P&gt;Age_Level = substr(tAge, 1,1);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without leading zero, the calculation is off for the values w/ fewer than three digits. For instance:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if tAge=525 then Age_Level=5 and New_Age=25&amp;nbsp;&lt;/P&gt;&lt;P&gt;If tAge=402 then Age_Level=4 and New_Age=2&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if tAge=95 then I want to add leading zero (095) so New_Age returns 95 and Age_Level returns 0&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 20:20:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406137#M279268</guid>
      <dc:creator>Kiko</dc:creator>
      <dc:date>2017-10-20T20:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406174#M279269</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;newage = mod(tAge,100);&lt;/P&gt;
&lt;P&gt;Age_level = int(tAge/100);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes this type of "need" indicates that a variable was read incorrectly. I suspect that your source data may have had leading zeroes and however that was read converted them to numeric which will not have leading 0 for values greater than 1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 21:59:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406174#M279269</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-20T21:59:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to add leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406215#M279271</link>
      <description>&lt;P&gt;To&amp;nbsp;&lt;EM&gt;display&lt;/EM&gt; a number with leading zeroes, use the Z. format. To&amp;nbsp;&lt;EM&gt;store&lt;/EM&gt; numbers with leading zeroes, you have to put them into character variables.&lt;/P&gt;</description>
      <pubDate>Sat, 21 Oct 2017 06:54:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-add-leading-zero/m-p/406215#M279271</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-21T06:54:17Z</dc:date>
    </item>
  </channel>
</rss>

