<?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: Sas dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699591#M214005</link>
    <description>&lt;P&gt;Partial date strings need special treatment (special informat, or append a day before converting).&lt;/P&gt;
&lt;P&gt;You also need to decide which day in the month is best for later analysis.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2020 18:49:55 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-11-17T18:49:55Z</dc:date>
    <item>
      <title>Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699586#M214004</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a question on SAS dates. I have a variable MHSTDTC which has dates like 2020-05 and also 2020-05-17. when i applied index function using PROC SQL like this&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;PROC SQL;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;CREATE TABLE MEDICAL AS&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;SELECT *,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;CASE WHEN INDEX (MHLNKID, 'D') THEN INPUT(MHSTDTC, YYMMDD10.) END AS C FORMAT=YYMMDD10.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;FROM M&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;ORDER BY SUBJID;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;QUIT;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output will display only dates like '2020-05-17' while the ones like '2020-05' will not display.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How will i display both dates in my output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 18:46:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699586#M214004</guid>
      <dc:creator>chimukah</dc:creator>
      <dc:date>2020-11-17T18:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699591#M214005</link>
      <description>&lt;P&gt;Partial date strings need special treatment (special informat, or append a day before converting).&lt;/P&gt;
&lt;P&gt;You also need to decide which day in the month is best for later analysis.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 18:49:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699591#M214005</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-17T18:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699592#M214006</link>
      <description>&lt;P&gt;Use the&amp;nbsp;&lt;SPAN&gt;B8601DA informat as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;&amp;nbsp;in the thread &lt;A href="https://communities.sas.com/t5/SAS-Programming/Partial-date-char-to-num/m-p/698671#M213688" target="_self"&gt;here&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 18:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699592#M214006</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-11-17T18:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699593#M214007</link>
      <description>&lt;P&gt;Thank you KurtBremen for your suggestion. However the day is missing as can be seen from the partial date '2020-05'. I feel there's a way to get around it and display both even if its partial.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 18:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699593#M214007</guid>
      <dc:creator>chimukah</dc:creator>
      <dc:date>2020-11-17T18:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699595#M214008</link>
      <description>&lt;P&gt;Since dates are stored as the number of days since 1960 you cannot make a date value without specifying the full date, including what day of the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to display a "date" that does not have a day of the month then just leave it as a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If did pick a day of the month to use so that you can generate a date value you could have it display just the year and month by using a format that only shows that level of detail.&amp;nbsp; This is similar to how you can use a format to limit the number of decimal places displayed for a number.&amp;nbsp; So formats like YYMMN7. or MONYY7.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 19:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699595#M214008</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-17T19:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699596#M214009</link>
      <description>&lt;P&gt;A date is a date is a date is a date. A date specifies a specific day within a specific month within a specific year.&lt;/P&gt;
&lt;P&gt;To have usable date values in SAS, you need to have that specific day, so there is no way around that.&lt;/P&gt;
&lt;P&gt;To help later users, you can keep separate year/month/day values, and let the users decide how to handle the missing values.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 19:42:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699596#M214009</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-17T19:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699597#M214010</link>
      <description>&lt;P&gt;What's the danger of using anydtdte10. in place of yymmdd10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried it and it gave first day of the month.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 19:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699597#M214010</guid>
      <dc:creator>chimukah</dc:creator>
      <dc:date>2020-11-17T19:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699598#M214011</link>
      <description>&lt;P&gt;There's no danger. Until somebody finds out that most cars are stolen on the first days of months.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 19:45:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699598#M214011</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-17T19:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sas dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699620#M214016</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225077"&gt;@chimukah&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;What's the danger of using anydtdte10. in place of yymmdd10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried it and it gave first day of the month.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The danger is what it does with ambiguous strings like:&lt;/P&gt;
&lt;PRE&gt;01-02-03&lt;/PRE&gt;
&lt;P&gt;If you read that with the YYMMDD informat or the B8601DA informat then it will always interpret the first value as the year, the second as the month and the third as the day (03FEB2001).&amp;nbsp; But ANYDTDTE will not.&amp;nbsp; Instead if will either treat it as DMY (01FEB2003) or MDY(02JAN2003) depending on the setting of you language/region options.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 20:43:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sas-dates/m-p/699620#M214016</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-11-17T20:43:31Z</dc:date>
    </item>
  </channel>
</rss>

