<?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: Database dropped leading zeros... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155528#M30435</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have the solution to your SAS problem (format Z7.)&lt;/P&gt;&lt;P&gt;Just in case it is something you might need to do also in excel, the corresponding formula is =text(A1,"0000000"), where that "0000000" is the format in which to present the value in cell A1&lt;/P&gt;&lt;P&gt;With that formula you shouldn't lose the digits that you demonstrate in your example &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; =RIGHT("000000"&amp;amp;A1,7)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Nov 2013 17:58:57 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2013-11-25T17:58:57Z</dc:date>
    <item>
      <title>Database dropped leading zeros...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155522#M30429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Slight annoyance on my part, but the database that I query has one field that is formatted as a number instead of text. As a result, when the value should be 0001234, it becomes 1234.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is only a problem when I'm cross matching between the database and established reports that have the leading zeros. It won't get an exact match unless I change one or the other.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The preferred format that management likes to see is with the leading zeros.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when running the compare queries, I export to excel to use the formula =RIGHT("000000"&amp;amp;A1,7)&lt;/P&gt;&lt;P&gt;This adds zeros on the front end, then only gives me last 7 numbers. (1234 becomes 0001234, While 12 becomes 0000012)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to do this with a data step in SAS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've only found SUBSTR function, which seems to work more like the excel =MID() formula.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155522#M30429</guid>
      <dc:creator>EarlyCode</dc:creator>
      <dc:date>2013-11-25T15:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Database dropped leading zeros...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155523#M30430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If it's stored as a numeric, and you work with it as a numeric, the leading zeroes are irrelevant.&amp;nbsp; If you work with it as a character, ie with PUT(), you need to PUT it with the format z7. (or however wide it should be).&amp;nbsp; Zw.d is the zero-padded format, so put(1234,Z7.) = 0001234.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155523#M30430</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2013-11-25T15:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: Database dropped leading zeros...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155524#M30431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please try to use the format z8., it will display the data with leading zeros. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jagadish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155524#M30431</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2013-11-25T15:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Database dropped leading zeros...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155525#M30432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The field is "Package_No" and I will need to convert all pulled values to characters. But when I create a data step with Put(Package_No,Z7.); I get a syntax error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;101 Put(Package_No,z7.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 76&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a name, arrayname, ), -, :, [, _ALL_,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;_CHARACTER_, _CHAR_, _NUMERIC_, {.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure what it's expecting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 16:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155525#M30432</guid>
      <dc:creator>EarlyCode</dc:creator>
      <dc:date>2013-11-25T16:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Database dropped leading zeros...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155526#M30433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you actually doing with the package_no variable?&amp;nbsp; Post an example of the entire process - how you want to match it up, with some dummy data.&amp;nbsp; You can't just 'put' something on its own, you have to assign that to a variable, or use a FORMAT statement (which changes how the variable is displayed, but not how it is used in sorts/merges).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 16:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155526#M30433</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2013-11-25T16:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Database dropped leading zeros...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155527#M30434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;package_no=1234;&lt;/P&gt;&lt;P&gt;package_char = put(package_no, z7.);&lt;/P&gt;&lt;P&gt;put package_char;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 16:38:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155527#M30434</guid>
      <dc:creator>jaredp</dc:creator>
      <dc:date>2013-11-25T16:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Database dropped leading zeros...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155528#M30435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have the solution to your SAS problem (format Z7.)&lt;/P&gt;&lt;P&gt;Just in case it is something you might need to do also in excel, the corresponding formula is =text(A1,"0000000"), where that "0000000" is the format in which to present the value in cell A1&lt;/P&gt;&lt;P&gt;With that formula you shouldn't lose the digits that you demonstrate in your example &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; =RIGHT("000000"&amp;amp;A1,7)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 17:58:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Database-dropped-leading-zeros/m-p/155528#M30435</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2013-11-25T17:58:57Z</dc:date>
    </item>
  </channel>
</rss>

