<?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: Add leading zeros to numeric variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/543427#M150216</link>
    <description>&lt;P&gt;You already achieved that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds4;
infile datalines;
input number;
format number Z10.;
datalines;
1
11
111
1111
11111
111111
1111111
11111111
111111111
1111111111
;
run;

proc print data=ds4 noobs;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;    number

0000000001
0000000011
0000000111
0000001111
0000011111
0000111111
0001111111
0011111111
0111111111
1111111111
&lt;/PRE&gt;
&lt;P&gt;A number does not &lt;EM&gt;have&lt;/EM&gt; leading zeroes by definition, but it can be &lt;EM&gt;displayed&lt;/EM&gt; with leading zeroes, and your format does that.&lt;/P&gt;
&lt;P&gt;If you need to &lt;EM&gt;store&lt;/EM&gt; leading zeroes (eg if your number is not a number for calculation, but identification), you have to store the value in a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;how to add leading zeros&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DS4; INFILE DATALINES; INPUT NUMBER; FORMAT NUMBER Z10.; DATALINES; 1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 ; RUN; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Mar 2019 07:39:40 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-03-15T07:39:40Z</dc:date>
    <item>
      <title>Add leading zeros to numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/543425#M150215</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;how to add leading zeros&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DS4; INFILE DATALINES; INPUT NUMBER; FORMAT NUMBER Z10.; DATALINES; 1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 ; RUN; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Mar 2019 07:32:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/543425#M150215</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-03-15T07:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Add leading zeros to numeric variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/543427#M150216</link>
      <description>&lt;P&gt;You already achieved that:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds4;
infile datalines;
input number;
format number Z10.;
datalines;
1
11
111
1111
11111
111111
1111111
11111111
111111111
1111111111
;
run;

proc print data=ds4 noobs;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;    number

0000000001
0000000011
0000000111
0000001111
0000011111
0000111111
0001111111
0011111111
0111111111
1111111111
&lt;/PRE&gt;
&lt;P&gt;A number does not &lt;EM&gt;have&lt;/EM&gt; leading zeroes by definition, but it can be &lt;EM&gt;displayed&lt;/EM&gt; with leading zeroes, and your format does that.&lt;/P&gt;
&lt;P&gt;If you need to &lt;EM&gt;store&lt;/EM&gt; leading zeroes (eg if your number is not a number for calculation, but identification), you have to store the value in a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;how to add leading zeros&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA DS4; INFILE DATALINES; INPUT NUMBER; FORMAT NUMBER Z10.; DATALINES; 1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111 ; RUN; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2019 07:39:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/543427#M150216</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-03-15T07:39:40Z</dc:date>
    </item>
  </channel>
</rss>

