<?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: Padding a text variable with leading 0s in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Padding-a-text-variable-with-leading-0s-SOLVED-MACROISED/m-p/27546#M5068</link>
    <description>Nevermind - I discovered the REPEAT function.&lt;BR /&gt;
&lt;BR /&gt;
Here's a solution in macro format, to stop this topic being a waste of space...&lt;BR /&gt;
%macro fillfromleftwithzero(table,variable,varlen);&lt;BR /&gt;
data &amp;amp;table.;&lt;BR /&gt;
set &amp;amp;table.;&lt;BR /&gt;
&amp;amp;variable. = REPEAT("0",&amp;amp;varlen.-length(&amp;amp;variable.)) || &amp;amp;variable.;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend; /*fillfromleftwithzero*/</description>
    <pubDate>Wed, 25 Jun 2008 04:00:02 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-06-25T04:00:02Z</dc:date>
    <item>
      <title>Padding a text variable with leading 0s [SOLVED, MACROISED SOLUTION INSIDE]</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Padding-a-text-variable-with-leading-0s-SOLVED-MACROISED/m-p/27545#M5067</link>
      <description>I'm in the final stages of a data standardisation effort here at work.&lt;BR /&gt;
There are two data columns, each being of type CHAR.  They mostly contain numeric IDs, but some contain letters in the middle of the number strings as well.  What I wish to do is ensure that all of the variables contain 10 characters, and if they contain less than that, pad out the left-hand-side with 0s.  &lt;BR /&gt;
If the variables were guaranteed to be wholly numeric I would simply convert to a number and then use PUT with the Zw. format, but that isn't applicable here.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestions?</description>
      <pubDate>Wed, 25 Jun 2008 00:55:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Padding-a-text-variable-with-leading-0s-SOLVED-MACROISED/m-p/27545#M5067</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-25T00:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Padding a text variable with leading 0s</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Padding-a-text-variable-with-leading-0s-SOLVED-MACROISED/m-p/27546#M5068</link>
      <description>Nevermind - I discovered the REPEAT function.&lt;BR /&gt;
&lt;BR /&gt;
Here's a solution in macro format, to stop this topic being a waste of space...&lt;BR /&gt;
%macro fillfromleftwithzero(table,variable,varlen);&lt;BR /&gt;
data &amp;amp;table.;&lt;BR /&gt;
set &amp;amp;table.;&lt;BR /&gt;
&amp;amp;variable. = REPEAT("0",&amp;amp;varlen.-length(&amp;amp;variable.)) || &amp;amp;variable.;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend; /*fillfromleftwithzero*/</description>
      <pubDate>Wed, 25 Jun 2008 04:00:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Padding-a-text-variable-with-leading-0s-SOLVED-MACROISED/m-p/27546#M5068</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-06-25T04:00:02Z</dc:date>
    </item>
  </channel>
</rss>

