<?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: Working with Dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107125#M22311</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Oct 2013 00:08:19 GMT</pubDate>
    <dc:creator>jcis7</dc:creator>
    <dc:date>2013-10-10T00:08:19Z</dc:date>
    <item>
      <title>Working with Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107119#M22305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to determine if each person received a shot by the time they're&amp;nbsp; certain age and also if they've received it by the time they enter a program (specified calendar date)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you suggest I do?&lt;BR /&gt;I've programs left by someone else which I've tried modifiying and they used months.&lt;/P&gt;&lt;P&gt;The birthdate and shot dates are 2 digit month, 2 digit day, and 2 digit year. So, we can convert to a sasdate using&amp;nbsp; birthdate=mdy(month, day, year) and shotdate=mdy(month, day, year).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question 1:&lt;/P&gt;&lt;P&gt;How do I determine if they've received a shot by up to 10 days before age 4 years?&amp;nbsp; Using the old code which uses months,&amp;nbsp; i can multiply 48*30.4375 to get age 4 years.&amp;nbsp; Does that give me how old the child is in sasdate in months? If so, how do I get a sasdate for the age in months including a 10 day grace period?&amp;nbsp; Going even further, how do I get a sasdate in age in years?&amp;nbsp; is 48*30.4375 a sasdate for age 48 months and for 4 years or is it for only 48 months and there's a different sasdate for 4 years?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Question 2:&lt;/P&gt;&lt;P&gt;If I want to know&amp;nbsp; if they've received the shot not only by age 4 but also before a certain date after that, say by the time they enter a program&lt;/P&gt;&lt;P&gt;Do I convert the date they enter the program into a sasdate too ((enterdate=mdy(10,10,2010) for example.).&amp;nbsp; And, if the sasdate number they received the shot is greater than the sasdate for age 4 years (48*30.4375) and less than the program entry date, they've fulfilled the requirement? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, it'll be:&amp;nbsp; if&amp;nbsp;&amp;nbsp; 48*30.4375 &amp;lt; shotdate &amp;lt;enterdate then fulfilledrequirement=1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks very much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Oct 2013 23:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107119#M22305</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2013-10-08T23:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107120#M22306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;2 digit years? Do you only have people born after 2000, otherwise that could be an issue. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wouldn't recommend using the month/day approximations when you're checking for a 10 day interval. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SAS Dates are really numbers, the number of days since January 1, 1960 and you can subtract/add as required.&lt;/P&gt;&lt;P&gt;So create 3 dates using mdy function as indicated. Then use the intnx functions to increment dates and compare dates. Example for A is below.&lt;/P&gt;&lt;P&gt;shot_date_sas&lt;/P&gt;&lt;P&gt;birth_date_sas&lt;/P&gt;&lt;P&gt;program_start_sas&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can simplify the calculation as follows. You may need to modify the &amp;lt;= signs to get the comparisons you want. &lt;/P&gt;&lt;P&gt;*Calculate age at which a person turns 4;&lt;/P&gt;&lt;P&gt;age4_sas=intnx('year', birth_date_sas, 4, 's');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*calculate if shot by enter date;&lt;/P&gt;&lt;P&gt;if age4_sas-shot_date_sas&amp;gt;=10 then shot_by_4=1; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*if shot 10 days before 4 and program requirement;&lt;/P&gt;&lt;P&gt;if shot_by_4=1 and shot_date_sas&amp;lt;=program_start_sas then fulfilled_requirement=1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 00:05:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107120#M22306</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-09T00:05:19Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107121#M22307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For Q1: Look up function YRDIF(). And for the grace period simply deduct 10 days from toda().&lt;/P&gt;&lt;P&gt;&amp;nbsp; age=YRDIF(DoB,today(),'age'); &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a good idea to always use SAS dates. Using SAS dates you can take advantage of all the calendar functions like intnx(), intck(), yrdif() and so on.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 00:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107121#M22307</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2013-10-09T00:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107122#M22308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, birthdates are after 2000.&amp;nbsp; Thank you very much &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;What does the 's' mean?&amp;nbsp;&amp;nbsp;&amp;nbsp; I looked it up, and ti sames it is alignment but I don't understand: &lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212700.htm" title="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212700.htm"&gt;SAS(R) 9.2 Language Reference: Dictionary, Fourth Edition&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 23:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107122#M22308</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2013-10-09T23:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107123#M22309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Oct 2013 23:59:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107123#M22309</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2013-10-09T23:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107124#M22310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It increments the date 4 years in the future, but at the same date. You can use end/beginning to get the start/end of the year if you needed that type of calculation. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So Jan15, 2000 with the formula above would be Jan 15, 2004, so year is incremented by 4 and day/month stay the same.&amp;nbsp; You use this formula rather than adding 365 days because of leap years.&amp;nbsp; It "corrects" for Leap years, but you should verify the logic is what you want. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2013 00:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107124#M22310</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-10T00:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Working with Dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107125#M22311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2013 00:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Working-with-Dates/m-p/107125#M22311</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2013-10-10T00:08:19Z</dc:date>
    </item>
  </channel>
</rss>

