<?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 print a numeric SAS variable with leading zeros? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149734#M39487</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If my input is character, then how to add leading zeros for the variable with character datatype?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Aug 2014 07:34:46 GMT</pubDate>
    <dc:creator>RamKumar</dc:creator>
    <dc:date>2014-08-14T07:34:46Z</dc:date>
    <item>
      <title>How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149729#M39482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #575757;"&gt;I've a SAS variable which is numeric with the same length for all records and I need to modify with one leading zeros and it still be numeric for all records like below.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mobilenumber&lt;/P&gt;&lt;P&gt;9167642524&lt;/P&gt;&lt;P&gt;9167642525&lt;/P&gt;&lt;P&gt;9167642526&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To Be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mobilenumber&lt;/P&gt;&lt;P&gt;09167642524&lt;/P&gt;&lt;P&gt;09167642525&lt;/P&gt;&lt;P&gt;09167642526&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest&amp;nbsp; me to achieve this task&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 14:08:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149729#M39482</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-08-05T14:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149730#M39483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look at the &lt;A href="http://support.sas.com/documentation/cdl/en/leforinforref/64790/HTML/default/viewer.htm#p09lpr3kmbh8fen1qepuv6zc1ldd.htm"&gt;Zw.&lt;/A&gt; format&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 14:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149730#M39483</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2014-08-05T14:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149731#M39484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I already seen the Zw. format but I'm not sure how it can be incorporated in SAS code as it is been often used with Input and Put function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 14:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149731#M39484</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-08-05T14:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149732#M39485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use Format for Proc Print and Put to create a String:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data A;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Input Phone;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Format Phone Z11.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Text=Put(Phone,Z11.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Datalines;&lt;/P&gt;&lt;P&gt;9167642524&lt;/P&gt;&lt;P&gt;9167642525&lt;/P&gt;&lt;P&gt;9167642526&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 14:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149732#M39485</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2014-08-05T14:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149733#M39486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could apply it to the number variable, or you can create a new character variable and put the number into the Z format.&amp;nbsp; Or you could apply the format in proc report etc.&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format mobilenumber z11.;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Aug 2014 14:44:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149733#M39486</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-05T14:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149734#M39487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If my input is character, then how to add leading zeros for the variable with character datatype?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 07:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149734#M39487</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-08-14T07:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149735#M39488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would prefer the Phone_Text-version which transforms the character to numeric over the Phone_Text2-version:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data A;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Input Phone $;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Text=Put(Input(Phone,Best11.),Z11.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Text2=Repeat('0',10-Length(Phone))!!Phone; /* use a Macro-Variable instead of 10 */&lt;/P&gt;&lt;P&gt;&amp;nbsp; Datalines;&lt;/P&gt;&lt;P&gt;9167642524&lt;/P&gt;&lt;P&gt;9167642525&lt;/P&gt;&lt;P&gt;9167642526&lt;/P&gt;&lt;P&gt;642526&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;Run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 07:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149735#M39488</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2014-08-14T07:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149736#M39489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hope one of below options will do for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; infile datalines truncover;&lt;/P&gt;&lt;P&gt;&amp;nbsp; input @1 Phone_Char $11. @1 Phone_Num 11.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Char2=cats('0',Phone_Char);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Char3=cats(repeat('0',10-lengthn(Phone_Char)),Phone_Char);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Char4=put(input(Phone_Char,11.),z11.);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Char5=prxchange('s/^(\d{10}) +$/0\1/oi',1,Phone_Char);&lt;/P&gt;&lt;P&gt;&amp;nbsp; Phone_Num2=Phone_Num;&lt;/P&gt;&lt;P&gt;&amp;nbsp; format Phone_Num2 z11.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; datalines;&lt;/P&gt;&lt;P&gt;9167642524&lt;/P&gt;&lt;P&gt;9167642525&lt;/P&gt;&lt;P&gt;9167642526&lt;/P&gt;&lt;P&gt;19167642526&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 07:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149736#M39489</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-08-14T07:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149737#M39490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks, but in the interest of time could you please tell me the significance of !! in the line &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Phone_Text2=Repeat('0',10-Length(Phone))!!Phone;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 08:38:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149737#M39490</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-08-14T08:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149738#M39491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If my input is character, then how to add leading zeros for the variable with character datatype?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 08:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149738#M39491</guid>
      <dc:creator>RamKumar</dc:creator>
      <dc:date>2014-08-14T08:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149739#M39492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Patrick has been nice enough to provide many examples of this.&amp;nbsp; The !! means concatenate.&amp;nbsp; What the code is doing is checking the existing length of Pone.&amp;nbsp; Then if less than 10 create a string of 0's to pad out to 10 length and concatenate these to Phone.&lt;/P&gt;&lt;P&gt;Also, it does not matter if you input is character and you want character out, you can still do put(input()) as User24feb has stated: Phone_Text=Put(Input(Phone,Best11.),Z11.);&lt;/P&gt;&lt;P&gt;This converts the string to number, uses Z. format to padd it, then puts it back to character and assigns the character result back into your original character format.&amp;nbsp; So you end up with the original variable with the data padded.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 08:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149739#M39492</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-08-14T08:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to print a numeric SAS variable with leading zeros?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149740#M39493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;!! is a concatenating operator. I use it instead of vertical bars (||). The reason is, that my keyboard does not have a solid vertical bar, so I use either two broken vertical bars (¦¦) or&amp;nbsp; two exclamation marks (!!).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 08:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-print-a-numeric-SAS-variable-with-leading-zeros/m-p/149740#M39493</guid>
      <dc:creator>user24feb</dc:creator>
      <dc:date>2014-08-14T08:56:35Z</dc:date>
    </item>
  </channel>
</rss>

