<?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 Help in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SAS-Date-Help/m-p/668086#M23073</link>
    <description>&lt;P&gt;SAS date valued variables are numeric and should have a format such as MMDDYY10. assigned.&lt;/P&gt;
&lt;P&gt;If your date variable is an actual SAS date value the code should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if Date &amp;gt;= '01OCT2019'd&lt;BR /&gt;then Variable= "X";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Literal dates must be in the date9 or date7(not recommended) 01OCT2019 format, in quotes and with the D to tell SAS that the value is intended to be a date.&lt;/P&gt;
&lt;P&gt;In some locals 10/01/2019 would be 10 January 2019 and if you do something like 01/02/03 it is impossible to tell which might actually be the year. So SAS uses the 'ddmmmyyyy'd as a way to know which specific date is intended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What your code is actually doing is telling SAS to divide 10 by 1, then divide that result by 2019.&lt;/P&gt;
&lt;P&gt;You could test that with code like:&lt;/P&gt;
&lt;PRE&gt;data junk;
  date='01JUN2018'd;
  z = 10/01/2019;
  if Date &amp;gt;= z then Variable= "X";
  if date &amp;gt;='01OCT2019'd then var2 = 'X';
run;&lt;/PRE&gt;
&lt;P&gt;A value of Z in that range will be considered to be 01Jan1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jul 2020 16:09:12 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-07-09T16:09:12Z</dc:date>
    <item>
      <title>SAS Date Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Date-Help/m-p/668078#M23071</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I have a very simple question using date variables but I can't seem to figure it out. I am working with a date variable in this format&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Date&lt;/P&gt;
&lt;P&gt;02/09/1996&lt;BR /&gt;02/09/1996&lt;BR /&gt;02/09/1996&lt;BR /&gt;06/19/1981&lt;BR /&gt;10/31/1954&lt;BR /&gt;10/09/1958&lt;BR /&gt;06/17/1960&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and I am trying to find all the variables where the Date is after October 1, 2019. So I am using this piece of code:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if Date &amp;gt;= 10/01/2019&lt;BR /&gt;then Variable= "X";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But I keep getting observations where the Date is before 10/01/2019 marked as "X".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 15:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Date-Help/m-p/668078#M23071</guid>
      <dc:creator>marleeakerson</dc:creator>
      <dc:date>2020-07-09T15:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Date-Help/m-p/668085#M23072</link>
      <description>&lt;P&gt;&lt;U&gt;If Date is a SAS date variable&lt;/U&gt;, use this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if Date ge '01Oct2019'd
    then variable = 'X';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will compare Date to a SAS date variable. (That is how you write a date as a SAS date variable: written as DDMonYYYY, with &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;'&lt;/STRONG&gt;&lt;/FONT&gt; before and&lt;FONT color="#FF0000"&gt; &lt;STRONG&gt;'d&lt;/STRONG&gt;&lt;/FONT&gt; after. Such as '17Feb1982'd)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;If Date is a character string&lt;/U&gt;, use this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if input(Date,mmddyy10.) ge '01Oct2019'd
    then variable = 'X';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That will convert the Date string to a SAS date value to compare with '01Oct2019'd.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 16:14:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Date-Help/m-p/668085#M23072</guid>
      <dc:creator>mklangley</dc:creator>
      <dc:date>2020-07-09T16:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Date Help</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-Date-Help/m-p/668086#M23073</link>
      <description>&lt;P&gt;SAS date valued variables are numeric and should have a format such as MMDDYY10. assigned.&lt;/P&gt;
&lt;P&gt;If your date variable is an actual SAS date value the code should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if Date &amp;gt;= '01OCT2019'd&lt;BR /&gt;then Variable= "X";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Literal dates must be in the date9 or date7(not recommended) 01OCT2019 format, in quotes and with the D to tell SAS that the value is intended to be a date.&lt;/P&gt;
&lt;P&gt;In some locals 10/01/2019 would be 10 January 2019 and if you do something like 01/02/03 it is impossible to tell which might actually be the year. So SAS uses the 'ddmmmyyyy'd as a way to know which specific date is intended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What your code is actually doing is telling SAS to divide 10 by 1, then divide that result by 2019.&lt;/P&gt;
&lt;P&gt;You could test that with code like:&lt;/P&gt;
&lt;PRE&gt;data junk;
  date='01JUN2018'd;
  z = 10/01/2019;
  if Date &amp;gt;= z then Variable= "X";
  if date &amp;gt;='01OCT2019'd then var2 = 'X';
run;&lt;/PRE&gt;
&lt;P&gt;A value of Z in that range will be considered to be 01Jan1960.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/ta-p/424354&lt;/A&gt; has a PDF with much information about dates.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jul 2020 16:09:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-Date-Help/m-p/668086#M23073</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-09T16:09:12Z</dc:date>
    </item>
  </channel>
</rss>

