<?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 Date Format Issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408349#M279470</link>
    <description>&lt;P&gt;I'm using SAS 9.4. I have two variables that are formatted as DATETIME20. I want to change the format to DATE9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	
set have;

format predate date9. postdate date9.;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The code works for the second half of the&amp;nbsp;dataset, but&amp;nbsp;the first half changes to "*******". I cannot figure out what I'm missing. Any help appreciated!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot.png" style="width: 433px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16277i8ABB470FFCCD7B1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot.png" alt="screenshot.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 29 Oct 2017 16:08:21 GMT</pubDate>
    <dc:creator>bg12</dc:creator>
    <dc:date>2017-10-29T16:08:21Z</dc:date>
    <item>
      <title>Date Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408349#M279470</link>
      <description>&lt;P&gt;I'm using SAS 9.4. I have two variables that are formatted as DATETIME20. I want to change the format to DATE9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
	
set have;

format predate date9. postdate date9.;

run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The code works for the second half of the&amp;nbsp;dataset, but&amp;nbsp;the first half changes to "*******". I cannot figure out what I'm missing. Any help appreciated!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot.png" style="width: 433px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16277i8ABB470FFCCD7B1F/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot.png" alt="screenshot.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 16:08:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408349#M279470</guid>
      <dc:creator>bg12</dc:creator>
      <dc:date>2017-10-29T16:08:21Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408351#M279471</link>
      <description>&lt;P&gt;Either you need to make the columns in your table wider ... or the data is not a valid SAS date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, how are you viewing these columns? What exact viewer are you using to see this data?&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 16:12:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408351#M279471</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-10-29T16:12:11Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408356#M279472</link>
      <description>&lt;P&gt;If your variables are currently datetimes, you will need to convert them to dates to be able to print them properly in a date format.&amp;nbsp; Note that by doing so, you may lose some information.&amp;nbsp; Datetimes are more specific, and refer to a particular second, while dates refer to a particular day.&amp;nbsp; Assuming you want to go ahead with this, the code would be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;predate = datepart(predate);&lt;/P&gt;
&lt;P&gt;postdate = datepart(postdate);&lt;/P&gt;
&lt;P&gt;format predate postdate date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also consider that the current values of PREDATE and POSTDATE might actually be a mix ... some dates and some datetimes.&amp;nbsp; You might have to consider which observations need to apply DATEPART and which don't.&amp;nbsp; For example, you might use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;if predate &amp;gt; '01Jan3000'd then predate = datepart(predate);&lt;/P&gt;
&lt;P&gt;if postdate &amp;gt; '01Jan3000'd then postdate = datepart(postdate);&lt;/P&gt;
&lt;P&gt;format predate postdate date9.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 16:39:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408356#M279472</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-29T16:39:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408358#M279473</link>
      <description>&lt;P&gt;I'm not sure what you mean... but here's a screenshot before I try to reformat them. In regards to viewer, I'm using results viewer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="screenshot2.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16278iEBF36BD632FFF9F9/image-size/large?v=v2&amp;amp;px=999" role="button" title="screenshot2.png" alt="screenshot2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 16:45:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408358#M279473</guid>
      <dc:creator>bg12</dc:creator>
      <dc:date>2017-10-29T16:45:21Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408367#M279474</link>
      <description>&lt;P&gt;Your data down to row row 190 is indeed SAS datetimes, and so as explained above, you need to convert them to SAS datees. Then after that the data is probably SAS dates, but formatted as datetimes, and so you get a date of 01JAN60. Somehow, your data is mismatched, some are dates and some are datetimes. You need to correct this first.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Oct 2017 17:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408367#M279474</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-10-29T17:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Date Format Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408420#M279475</link>
      <description>Thank you!</description>
      <pubDate>Sun, 29 Oct 2017 22:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-Format-Issue/m-p/408420#M279475</guid>
      <dc:creator>bg12</dc:creator>
      <dc:date>2017-10-29T22:30:07Z</dc:date>
    </item>
  </channel>
</rss>

