<?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/170729#M264233</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@aga11940&lt;/P&gt;&lt;P&gt;Then please mark the question as answered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 12 Dec 2013 08:56:44 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2013-12-12T08:56:44Z</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/170722#M264226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am a SAS newbie (3 months).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my project, I have 3 imported data sets that I need to join together on a primary key that is a numeric type. My challenge is that in two of the tables, the leading zeros do not exist, so the join will not match for those records without the leading zeros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Table1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;001001&lt;/P&gt;&lt;P&gt;001002&lt;/P&gt;&lt;P&gt;12345&lt;/P&gt;&lt;P&gt;54321&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="line-height: 1.5em; font-size: 10pt; text-decoration: underline;"&gt;Table2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;1001&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;1002&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;12345&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;54321&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;Table3&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1001&lt;/P&gt;&lt;P&gt;1002&lt;/P&gt;&lt;P&gt;12345&lt;/P&gt;&lt;P&gt;54321&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What can I do to add the leading zeros to the values that are missing leading zeros? The fixed length of the field is 5, so no leading zeros should be added to the values that have a non-zero number leading (e.g 12345, 10101).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 18:32:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170722#M264226</guid>
      <dc:creator>aga11940</dc:creator>
      <dc:date>2013-12-11T18:32:35Z</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/170723#M264227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Look at Z5. format.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 18:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170723#M264227</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-12-11T18:35:20Z</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/170724#M264228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Reeza, thanks for your quick response. I am not sure I follow however. &lt;/P&gt;&lt;P&gt;Could you please elaborate? Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 18:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170724#M264228</guid>
      <dc:creator>aga11940</dc:creator>
      <dc:date>2013-12-11T18:42:06Z</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/170725#M264229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you actually run the join? If so was there an error or warning message? Are the variables actually of type numeric? Your comment about fixed length of 5 makes it sound that the values are likely string containing digits.&lt;/P&gt;&lt;P&gt;Proc contents data=table1;run; (or what ever the actual library.dataset name for table 1 would show whether actual numeric or character)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you trying to do this as a pass through to another database or are the tables both SAS datasets?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 18:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170725#M264229</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2013-12-11T18:50:56Z</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/170726#M264230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. Numeric variables cannot have leading zeros, so it has to be a character variable. &lt;/P&gt;&lt;P&gt;2. You can convert the number to a character by using the SAS format Z5.&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000205244.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000205244.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can merge the fields together on the new character field or use the conversin in your PROC SQL step. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 18:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170726#M264230</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-12-11T18:52:36Z</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/170727#M264231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'd be checking that the Table 1 import hasn't made your primary key a character variable first. If it's imported it as a number it shouldn't have the leading zeroes unless you've whacked a format on it. If that's the case convert it:&lt;/P&gt;&lt;P&gt;newvar = input(primary_key,5.) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 18:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170727#M264231</guid>
      <dc:creator>SteveNZ</dc:creator>
      <dc:date>2013-12-11T18:53:30Z</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/170728#M264232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you everyone! I was able to resolve this by converting the number variable to character using the format Z5.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate everyones input. This was great.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Dec 2013 19:19:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170728#M264232</guid>
      <dc:creator>aga11940</dc:creator>
      <dc:date>2013-12-11T19:19:29Z</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/170729#M264233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@aga11940&lt;/P&gt;&lt;P&gt;Then please mark the question as answered.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Dec 2013 08:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-leading-zeros-to-numeric-variable/m-p/170729#M264233</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-12-12T08:56:44Z</dc:date>
    </item>
  </channel>
</rss>

