<?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 as numeric in where clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807859#M318554</link>
    <description>My date is numeric, it is not a string. None of the approaches didn’t work.&lt;BR /&gt;Respectfully,&lt;BR /&gt;Blue</description>
    <pubDate>Thu, 14 Apr 2022 16:25:10 GMT</pubDate>
    <dc:creator>GN0001</dc:creator>
    <dc:date>2022-04-14T16:25:10Z</dc:date>
    <item>
      <title>Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807729#M318501</link>
      <description>Hello team, &lt;BR /&gt;I have a variable as date numeric as mm/did/yyyy. I want to use it in a where clause: where dob= 12/10/2021; &lt;BR /&gt;SAS ignores it and returns other dates in the result, how can I fix this issue? &lt;BR /&gt;Blueblue</description>
      <pubDate>Thu, 14 Apr 2022 07:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807729#M318501</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-04-14T07:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807735#M318504</link>
      <description>Use IF Clause instead where</description>
      <pubDate>Thu, 14 Apr 2022 08:15:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807735#M318504</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2022-04-14T08:15:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807736#M318505</link>
      <description>&lt;P&gt;try use this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where dob=input('12/10/2021',mmddyy10.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Apr 2022 08:17:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807736#M318505</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-04-14T08:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807737#M318506</link>
      <description>But I don’t want to convert to literal. Thanks blue</description>
      <pubDate>Thu, 14 Apr 2022 08:28:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807737#M318506</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-04-14T08:28:33Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807738#M318507</link>
      <description>&lt;P&gt;then try&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where dob=22624;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where dob='10dec2021'd;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;12/10/2021 is not not a date for SAS.&lt;/P&gt;
&lt;P&gt;So it must be converted to a SAS date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 08:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807738#M318507</guid>
      <dc:creator>japelin</dc:creator>
      <dc:date>2022-04-14T08:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807740#M318508</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello team, &lt;BR /&gt;I have a variable as date numeric as mm/did/yyyy. I want to use it in a where clause: where dob= 12/10/2021; &lt;BR /&gt;SAS ignores it and returns other dates in the result, how can I fix this issue? &lt;BR /&gt;Blueblue&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;12/10/2021 is not numeric, but a &lt;EM&gt;string &lt;/EM&gt;&lt;FONT color="#3366FF"&gt;EDIT: not a string, of course, if there are not quotes, but an expression, as Kurt already pointed out&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;so what do you have in dob? If it is not a sas-date, &lt;STRONG&gt;fix this issue first&lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 08:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807740#M318508</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-04-14T08:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807744#M318511</link>
      <description>In SAS, 12/10/2021 means 12 divided by 10, divided by 2021.  You don't have to convert your data but you do have to express the value you are comparing to as a date literal:&lt;BR /&gt;&lt;BR /&gt;where date = '10dec2021'n;&lt;BR /&gt;&lt;BR /&gt;SAS doesn't care whether you want to do this or not.&lt;BR /&gt;&lt;BR /&gt;If you are pulling the data from a database instead of a SAS dataset,  the database may impose an entirely different syntax.</description>
      <pubDate>Thu, 14 Apr 2022 08:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807744#M318511</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-04-14T08:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807746#M318513</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;12/10/2021&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;is a mathematical formula and results in 12 divided by 10 divided by 2021, so a very small number, which creates a SAS date of 01jan1960.&lt;/P&gt;
&lt;P&gt;Either use a SAS date literal:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"12oct2021"d&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or the INPUT function, as shown by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;. Even with quotes around it, your string is not a SAS date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please (and I am telling you this for the umpteenth time now)&amp;nbsp;&lt;STRONG&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lrcon/p1wj0wt2ebe2a0n1lv4lem9hdc0v.htm" target="_blank" rel="noopener"&gt;STUDY THE DOCUMENTATION&lt;/A&gt;!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 08:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807746#M318513</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-14T08:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807747#M318514</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;But I don’t want to convert to literal. Thanks blue&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226565"&gt;@japelin&lt;/a&gt;&amp;nbsp;posted is in NO WAY a "conversion to literal", it is a conversion of&amp;nbsp;&lt;EM&gt;your string&lt;/EM&gt; to a SAS date value.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 08:55:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807747#M318514</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-14T08:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807761#M318520</link>
      <description>&lt;P&gt;If your SAS data set contains values that are dates (numeric and have some date format such as date9. or yymmdd10. assigned for readability) and you want to provide a literal value for comparison the value must be in the form 'ddMONyy'd&lt;/P&gt;
&lt;P&gt;the year can be 2 or 4 digits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So a where clause to test if an existing variable is&lt;/P&gt;
&lt;PRE&gt;where dob= '10DEC2021'd; &lt;/PRE&gt;
&lt;P&gt;the quotes and D following (no space) are what tells SAS you intend to used this as a date literal value.&lt;/P&gt;
&lt;P&gt;Why that form? Likely because there are so many different strings of numbers that can represent dates (just look at the supplied SAS date formats for the common ones) that trying to program something that recognizes random digits as a date without some indication is night mare.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that doesn't work then you need to provide a data step that recreates your values. Likely you would be needing to create a proper date value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And before you ask, SAS uses the numeric value for comparison. The only time SAS would use the FORMATTED value in a comparison is if you force it by using something like:&lt;/P&gt;
&lt;PRE&gt;If put(datevar,yymmdd10.) = '2021/01/01';&lt;/PRE&gt;
&lt;P&gt;Not recommended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 10:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807761#M318520</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-14T10:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807853#M318552</link>
      <description>Hello,&lt;BR /&gt;Does this filter my numeric date!?&lt;BR /&gt;Respectfully &lt;BR /&gt;Blueblue</description>
      <pubDate>Thu, 14 Apr 2022 16:12:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807853#M318552</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-04-14T16:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807859#M318554</link>
      <description>My date is numeric, it is not a string. None of the approaches didn’t work.&lt;BR /&gt;Respectfully,&lt;BR /&gt;Blue</description>
      <pubDate>Thu, 14 Apr 2022 16:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807859#M318554</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2022-04-14T16:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807865#M318556</link>
      <description>&lt;P&gt;Post usable example data, so we know what we have to code against.&lt;/P&gt;
&lt;P&gt;(usable = data step with datalines).&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 16:37:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807865#M318556</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-14T16:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Date as numeric in where clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807939#M318579</link>
      <description>&lt;P&gt;Check the TYPE , LENGTH and any FORMAT that is attached to your variable.&lt;/P&gt;
&lt;P&gt;If the TYPE is NUM then check the range of the values using PROC MEANS or PROC SQL.&lt;/P&gt;
&lt;P&gt;If the variable has DATE values then the range of values would probably fall in the interval from today's date, which is day number&amp;nbsp;22,749 down to the earliest date in your data.&amp;nbsp; For example if you date goes back to beginning of 1960 then the smallest value is zero.&amp;nbsp; If it goes back further you might have negative numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the variable has instead DATETIME values (number of seconds) then value falls in the interval from now, which second number&amp;nbsp;1,965,578,801 down to the earliest timepoint in your data.&amp;nbsp; For example if you datetime values go back the start of 1960 then the smallest value is zero.&amp;nbsp; If it goes back further you might have negative numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your code does not work then please post the SAS log from the step you ran that did not work. Include any error messages and notes.&amp;nbsp; Make sure to use the Insert Code icon in the forum editor to paste the lines of text from the SAS log so the formatting is preserved.&amp;nbsp; If there are no error messages in the LOG then explain why you know it did not work.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 22:11:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Date-as-numeric-in-where-clause/m-p/807939#M318579</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-14T22:11:27Z</dc:date>
    </item>
  </channel>
</rss>

