<?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 date comparison failure in SAS 9.2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330655#M271868</link>
    <description>&lt;P&gt;Your dates are character strings and the comparisons won't work. If you use YYMMDD then it will sort correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can use SAS dates, which are numeric and then apply the relevant formats. This is the solution Art has proposed and probably the best.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Feb 2017 23:17:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-02-07T23:17:29Z</dc:date>
    <item>
      <title>SAS date comparison failure in SAS 9.2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330644#M271866</link>
      <description>&lt;P&gt;Hello! Need your help.&lt;/P&gt;&lt;P&gt;I&amp;nbsp;have to compare Dates, and based on&amp;nbsp;Date assign data to 2 different data sets (using SAS 9.2).&lt;/P&gt;&lt;P&gt;Here is what I have:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%Let&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; EffectiveDate = &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%sysfunc&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;(compress(&amp;amp;NewPrice,,kd)); &lt;/FONT&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;*Determine effective date of the most recent rate;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; &amp;amp;effectiveDate; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;No problem here, program prints for me EffectiveDate&amp;nbsp;say 011517;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Then I read data set with original Dates as&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Date1 :&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;$10&lt;/FONT&gt;&amp;nbsp; from some text tab delimetered file. No problem.&lt;/P&gt;&lt;P&gt;I convert this Date1 to Date to match format&amp;nbsp; of EffectiveDate:&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Date2=input(Date1, &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;mmddyy10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Date= put(Date2, &lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;mmddyy6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;Now I need to divide data based on Date into 2 data sets:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data&amp;nbsp;A B;&lt;/P&gt;&lt;P&gt;set abc;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;ChRateDay = input(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;"&amp;amp;EffectiveDate"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;mmddyy6.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;if Date &amp;lt; ChRateDay then output A;&lt;/P&gt;&lt;P&gt;else output B;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get all data in set A and nothing in set B. There are no errors in the log.&lt;/P&gt;&lt;P&gt;Original data set has data both prior and past "effective date"&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 22:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330644#M271866</guid>
      <dc:creator>User12321</dc:creator>
      <dc:date>2017-02-07T22:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date comparison failure in SAS 9.2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330650#M271867</link>
      <description>&lt;P&gt;From your description it's hard to tell what you are actually working with, but the following seems to mimic what you said, and produces the desired result:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%let EffectiveDate=011517;

data abc;
  input date $10.;
  cards;
052516
020717
;
data A B;
  set abc;
  if input(Date,mmddyy6.) &amp;lt; input("&amp;amp;EffectiveDate.",mmddyy6.) then output A;
  else output B;
run;
&lt;/PRE&gt;
&lt;P&gt;HTH,&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 22:58:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330650#M271867</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-02-07T22:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date comparison failure in SAS 9.2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330655#M271868</link>
      <description>&lt;P&gt;Your dates are character strings and the comparisons won't work. If you use YYMMDD then it will sort correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or you can use SAS dates, which are numeric and then apply the relevant formats. This is the solution Art has proposed and probably the best.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 23:17:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330655#M271868</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-07T23:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date comparison failure in SAS 9.2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330658#M271869</link>
      <description>&lt;P&gt;Did you see any notes about character values being converted to numeric or numeric to character in the log?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 23:36:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330658#M271869</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-07T23:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date comparison failure in SAS 9.2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330667#M271870</link>
      <description>&lt;P&gt;Thanks a lot!&lt;BR /&gt;It worked this way.&lt;/P&gt;&lt;P&gt;I guess problem was that I did not use input for Date in comparision.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 23:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330667#M271870</guid>
      <dc:creator>User12321</dc:creator>
      <dc:date>2017-02-07T23:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date comparison failure in SAS 9.2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330669#M271871</link>
      <description>&lt;P&gt;Yew, there was some character conversion, and I thought it was related to data.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Feb 2017 23:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330669#M271871</guid>
      <dc:creator>User12321</dc:creator>
      <dc:date>2017-02-07T23:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS date comparison failure in SAS 9.2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330709#M271872</link>
      <description>&lt;P&gt;Such notes should be fixed by correcting the data types of the variables involved - while &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13711"&gt;@art297&lt;/a&gt;'s fix works you shouldn't need to convert date variables to compare them. Storing them as SAS dates to begin with would be considered best practice and will simplify your coding.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 04:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-date-comparison-failure-in-SAS-9-2/m-p/330709#M271872</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2017-02-08T04:08:19Z</dc:date>
    </item>
  </channel>
</rss>

