<?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 zero max of 10 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740856#M231502</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp; Yet another easy and lazy alternative-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length
  loan_number $10
  
;
input loan_number ;

datalines;
2323333
22345099
112009899
345566
;
run;

data want;
 set have;
 length need $10;
 need=translate(right(loan_number),'0',' ');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Logic-&lt;/P&gt;
&lt;P&gt;Move the contents to the right. Fill the blanks with 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 May 2021 16:34:49 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2021-05-12T16:34:49Z</dc:date>
    <item>
      <title>Add Leading zero max of 10</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740845#M231494</link>
      <description>&lt;PRE&gt;data have;
length
  loan_number $10
  
;
input loan_number ;

datalines;
2323333
22345099
112009899
345566
;
run;

data have2;
set have;
ln_no=put(loan_number,z10.);
run;&lt;BR /&gt;&lt;BR /&gt;I ran the code and received format not found.  Note this is a character variable.  I want to assign leading zeros as needed to get a max 10 digit number in character format&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 May 2021 16:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740845#M231494</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2021-05-12T16:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: Add Leading zero max of 10</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740850#M231497</link>
      <description>Your original variable needs to be numeric. Convert it to a number and then apply the Z format. &lt;BR /&gt;&lt;BR /&gt;ln_no = put( input(Loan_number, best12.), z10.);</description>
      <pubDate>Wed, 12 May 2021 16:19:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740850#M231497</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-12T16:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Add Leading zero max of 10</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740852#M231498</link>
      <description>&lt;P&gt;In SAS there's always another way / different approach:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length
  		loan_number $10 ;
	input loan_number ;
	loan_number=substr("0000000000"||loan_number,length(loan_number)) ;

datalines;
2323333
22345099
112009899
345566
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 May 2021 16:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740852#M231498</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-05-12T16:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Add Leading zero max of 10</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740854#M231500</link>
      <description>Most definitely....I think there's at least two other ways to solve this I can think about, one using REPEAT() and another using SUBSTR() as well.</description>
      <pubDate>Wed, 12 May 2021 16:31:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740854#M231500</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-12T16:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: Add Leading zero max of 10</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740855#M231501</link>
      <description>&lt;P&gt;Close.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input loan_number $10.;
  put loan_number $10. ' -&amp;gt; ' @;
	loan_number=substr("0000000000"||loan_number,1+lengthn(loan_number)) ;
  put loan_number;
datalines;

1234567890
2323333
22345099
112009899
345566
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;           -&amp;gt; 0000000000
1234567890 -&amp;gt; 1234567890
2323333    -&amp;gt; 0002323333
22345099   -&amp;gt; 0022345099
112009899  -&amp;gt; 0112009899
345566     -&amp;gt; 0000345566
&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 May 2021 16:31:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740855#M231501</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-12T16:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Add Leading zero max of 10</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740856#M231502</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp; Yet another easy and lazy alternative-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
length
  loan_number $10
  
;
input loan_number ;

datalines;
2323333
22345099
112009899
345566
;
run;

data want;
 set have;
 length need $10;
 need=translate(right(loan_number),'0',' ');
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Logic-&lt;/P&gt;
&lt;P&gt;Move the contents to the right. Fill the blanks with 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 16:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-Leading-zero-max-of-10/m-p/740856#M231502</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-05-12T16:34:49Z</dc:date>
    </item>
  </channel>
</rss>

