<?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: How to convert to date9 while using a where clause in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791928#M40187</link>
    <description>Thank you! I checked and Due Date is a character rather than numeric.&lt;BR /&gt;&lt;BR /&gt;How would I convert from character to numeric?</description>
    <pubDate>Mon, 24 Jan 2022 17:15:30 GMT</pubDate>
    <dc:creator>Maria8</dc:creator>
    <dc:date>2022-01-24T17:15:30Z</dc:date>
    <item>
      <title>How to convert to date9 while using a where clause</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791770#M40183</link>
      <description>&lt;P&gt;I have two columns that I need to compare the dates to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 1 is labeled as Due Date, Column 2 is Date Returned.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to find rows that show when the date returned is past the due date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column 1's format is 08Aug2020 and Column 2's format is 03Aug2020 00:00:00.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code that I'm using is:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Proc SQL;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create Table Past_Due As&amp;nbsp;&lt;/P&gt;&lt;P&gt;Select due_date, date_returned&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date format = date9.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where due_date &amp;lt;= date_returned&amp;nbsp;&lt;/P&gt;&lt;P&gt;Order by due_date&lt;/P&gt;&lt;P&gt;from workbook;&amp;nbsp;&lt;/P&gt;&lt;P&gt;quit;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are also a lot of empty cells in date_returned - will that be something to have a condition for?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The version is SAS EG 8.3&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 07:11:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791770#M40183</guid>
      <dc:creator>Maria8</dc:creator>
      <dc:date>2022-01-24T07:11:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert to date9 while using a where clause</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791777#M40184</link>
      <description>&lt;P&gt;Take a look at the datepart() function.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 07:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791777#M40184</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2022-01-24T07:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert to date9 while using a where clause</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791779#M40185</link>
      <description>&lt;P&gt;From what you show us, it is most likely that one variable is a date, while the other is a datetime. Which means you need to use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p0rttbu7w62xgzn1damccyuwpld8.htm" target="_blank" rel="noopener"&gt;DATEPART&lt;/A&gt; function to extract the date from the datetime..&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 07:48:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791779#M40185</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-24T07:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert to date9 while using a where clause</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791885#M40186</link>
      <description>&lt;P&gt;&amp;lt;Pedantic mode/ON&amp;gt;&lt;/P&gt;
&lt;P&gt;Formats with SAS variables are properties for displaying values which have names. As such the phrase "Column 1's format is 08Aug2020 and Column 2's format is 03Aug2020 00:00:00." is incorrect. A format would be something like DATE9 in the first case. In the second I am not sure as the typical SAS datetime20. would not have a space between the year and the hour. You use Proc Contents to display the name of the format. Please use that to determine and share the Format assigned to Column 2 as the shown appearance for Column 2 is quite possibly Character if you do not have a custom format.&lt;/P&gt;
&lt;P&gt;&amp;lt;Pedantic mode/ OFF&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/389360"&gt;@Maria8&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have two columns that I need to compare the dates to.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Column 1 is labeled as Due Date, Column 2 is Date Returned.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to find rows that show when the date returned is past the due date.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Column 1's format is 08Aug2020 and Column 2's format is 03Aug2020 00:00:00.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code that I'm using is:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc SQL;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create Table Past_Due As&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Select due_date, date_returned&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date format = date9.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where due_date &amp;lt;= date_returned&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Order by due_date&lt;/P&gt;
&lt;P&gt;from workbook;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;quit;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are also a lot of empty cells in date_returned - will that be something to have a condition for?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The version is SAS EG 8.3&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jan 2022 16:12:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791885#M40186</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-24T16:12:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert to date9 while using a where clause</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791928#M40187</link>
      <description>Thank you! I checked and Due Date is a character rather than numeric.&lt;BR /&gt;&lt;BR /&gt;How would I convert from character to numeric?</description>
      <pubDate>Mon, 24 Jan 2022 17:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791928#M40187</guid>
      <dc:creator>Maria8</dc:creator>
      <dc:date>2022-01-24T17:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert to date9 while using a where clause</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791934#M40188</link>
      <description>&lt;P&gt;To convert character strings into numbers use the INPUT() function with an informat that understands how to convert the strings you have into dates.&amp;nbsp; So if DUE_DATE has values like '01JAN2020' then use the DATE9. informat.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(due_date,date9.)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If DUE_DATE has values like '01JAN2020 00:05:00' then you might be able to use the same statement as it will ignore all but the first 9 characters.&amp;nbsp; But if some of the strings have less that 8 or 9 characters to represent the date, such as '01JAN20 00:05' then you might want to first remove the characters after the space.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;input(scan(due_date,1,' '),date9.)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Jan 2022 17:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-convert-to-date9-while-using-a-where-clause/m-p/791934#M40188</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-01-24T17:37:38Z</dc:date>
    </item>
  </channel>
</rss>

