<?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: date dropping leading zero in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563368#M157929</link>
    <description>&lt;P&gt;Some more things to think about for this type of issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Leading zeros on numbers do not change the value stored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you are storing dates into character variables.&amp;nbsp; In that case I would recommend storing them using Year, Month, Day order so that when you sort in lexical order the values will also be in chronological order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you need to use four digits for the year.&amp;nbsp; My grandfather was born 98 and my son in 99 but they were born more than one year apart.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jun 2019 19:15:30 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-06-03T19:15:30Z</dc:date>
    <item>
      <title>date dropping leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563349#M157923</link>
      <description>&lt;P&gt;i have a field i created...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql NOPRINT;&lt;BR /&gt;CREATE TABLE TABLE (&lt;BR /&gt;...&lt;BR /&gt;FILEDATE char(8),&lt;BR /&gt;...);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then i filled that field...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;eom=put(intnx('month',today(),-1,'E'),mmddyy6.);&lt;BR /&gt;call symput('efiledt',eom);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data TABLE;&lt;BR /&gt;set TABLE;&lt;BR /&gt;FILEDATE=&amp;amp;efiledt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;okay, so my problem is that sas keeps dropping the leading zero and i need that leading zero to stay.&amp;nbsp; i tried formatting...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data TABLE;&lt;BR /&gt;set TABLE;&lt;BR /&gt;FILEDATE=put(FILEDATE,z6.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it did not like that...kept giving me a unknown format z error.&amp;nbsp; i thought that should be a character thus keeping that leading zero however that is not working.&amp;nbsp; how&amp;nbsp; can i adjust this to leave that leading zero on?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 17:43:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563349#M157923</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2019-06-03T17:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: date dropping leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563354#M157926</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/113010"&gt;@me55&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;i have a field i created...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql NOPRINT;&lt;BR /&gt;CREATE TABLE TABLE (&lt;BR /&gt;...&lt;BR /&gt;FILEDATE char(8),&lt;BR /&gt;...);&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then i filled that field...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;BR /&gt;eom=put(intnx('month',today(),-1,'E'),mmddyy6.);&lt;BR /&gt;call symput('efiledt',eom);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data TABLE;&lt;BR /&gt;set TABLE;&lt;BR /&gt;FILEDATE=&amp;amp;efiledt;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;okay, so my problem is that sas keeps dropping the leading zero and i need that leading zero to stay.&amp;nbsp; i tried formatting...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data TABLE;&lt;BR /&gt;set TABLE;&lt;BR /&gt;FILEDATE=put(FILEDATE,z6.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it did not like that...kept giving me a unknown format z error.&amp;nbsp; i thought that should be a character thus keeping that leading zero however that is not working.&amp;nbsp; how&amp;nbsp; can i adjust this to leave that leading zero on?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since you are using an implicit numeric to character in&lt;/P&gt;
&lt;PRE&gt;FILEDATE=&amp;amp;efiledt;&lt;/PRE&gt;
&lt;P&gt;that will happen because SAS does not have "leading zeroes" on numeric values.&lt;/P&gt;
&lt;P&gt;What you seem to want would be&lt;/P&gt;
&lt;PRE&gt;FILEDATE="&amp;amp;efiledt.";&lt;/PRE&gt;
&lt;P&gt;So that the macro value is treated as a character value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message you were getting is because since FILEDATE is character variable it expects any formats used with it, such as in PUT to be $defined variables. SAS tried to find a $Z format but there is not one by default. Zw.d is format for numeric values.&lt;/P&gt;
&lt;P&gt;You could have used&lt;/P&gt;
&lt;P&gt;Filedate= put(&amp;amp;efiledt. , z6.);&lt;/P&gt;
&lt;P&gt;but still awkward code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 18:07:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563354#M157926</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-06-03T18:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: date dropping leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563359#M157928</link>
      <description>&lt;P&gt;perfect...the quotes worked great to leave that leading zero on there.&amp;nbsp; thanks for the explanation, it helps me understand the underlying issue considerably!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 18:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563359#M157928</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2019-06-03T18:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: date dropping leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563368#M157929</link>
      <description>&lt;P&gt;Some more things to think about for this type of issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Leading zeros on numbers do not change the value stored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you are storing dates into character variables.&amp;nbsp; In that case I would recommend storing them using Year, Month, Day order so that when you sort in lexical order the values will also be in chronological order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also you need to use four digits for the year.&amp;nbsp; My grandfather was born 98 and my son in 99 but they were born more than one year apart.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jun 2019 19:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563368#M157929</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-06-03T19:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: date dropping leading zero</title>
      <link>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563533#M157997</link>
      <description>yeah i realize all of that stuff. i have no choice on that. i am rebuilding something not building it on my own.</description>
      <pubDate>Tue, 04 Jun 2019 14:24:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/date-dropping-leading-zero/m-p/563533#M157997</guid>
      <dc:creator>me55</dc:creator>
      <dc:date>2019-06-04T14:24:59Z</dc:date>
    </item>
  </channel>
</rss>

