<?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 dates conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177401#M264798</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Subtraction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 13 Jul 2014 16:26:52 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2014-07-13T16:26:52Z</dc:date>
    <item>
      <title>SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177398#M264795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have dates of events in SAS form, just number of days, but I would like to convert them to DDMMYYY and then extract the year so I can make a variable called "year of event". Is there an easy way to do this? Please provide code if possible. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 12:50:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177398#M264795</guid>
      <dc:creator>Mdormond</dc:creator>
      <dc:date>2014-07-13T12:50:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177399#M264796</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a numeric variable that looks like a date when printed with a date format then you can use the YEAR() function to extract the year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;year_of_event = year(date_of_event) ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if your date variable is instead a character string that just looks like a date then you can first convert it to a date using the proper informat. For example if you values look like 13JUL2014 then you would use code like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;year_of_event = year(input(date_of_event,date9.);&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 14:51:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177399#M264796</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-13T14:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177400#M264797</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that was very helpful! Unfortunately, my dates are actually from the beginning of the study period (1998), is there anyway to make the "year" variable count from this date instead of the SAS default date?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 16:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177400#M264797</guid>
      <dc:creator>Mdormond</dc:creator>
      <dc:date>2014-07-13T16:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177401#M264798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Subtraction.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 16:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177401#M264798</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-13T16:26:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177402#M264799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the beginning is a constant then just subtract it. If it exists in another variable then reference the other variable.&lt;/P&gt;&lt;P&gt;For example to count beginning with 1 you could use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;study_year = year(event_date) - 1988 + 1 ;&lt;/P&gt;&lt;P&gt;study_year = year(event_data) - year(study_start_date) + 1;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to treat the interval from 01AUG1998 to 01JAN1990 as less than two years then you might want to use the INTCK() function.&lt;/P&gt;&lt;P&gt;study_year = intck('year',study_start_date,event_date,'C') ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 16:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177402#M264799</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-13T16:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177403#M264800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you mean your dates are the number of days since the beginning of the study? Then add them to the study start date and take the year to get the calendar year.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;year = year(study_day + study_start_date -1) ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 17:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177403#M264800</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-13T17:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177404#M264801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have date of event in numeric form (i.e. 915) and those are days from the study start period 1998. I want to determine what year the event occurred in. Should I add 915 days to the beginning of the study period to get year of event? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 17:34:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177404#M264801</guid>
      <dc:creator>Mdormond</dc:creator>
      <dc:date>2014-07-13T17:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177405#M264802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Answer as already provided by &lt;A __default_attr="2746" __jive_macro_name="user" class="jive_macro jive_macro_user" data-objecttype="3" href="https://communities.sas.com/"&gt;&lt;/A&gt; in your other post asking the same question&amp;nbsp; &lt;A __default_attr="219644" __jive_macro_name="message" class="jive_macro jive_macro_message" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 22:21:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177405#M264802</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2014-07-13T22:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS dates conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177406#M264803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So if the study start date is a constant then just use a date literal for the calculation.&lt;/P&gt;&lt;P&gt;Assuming study day number 1 is 01JAN1988 then you would use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;year = year(study_day + "01JAN1988"d -1) ;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 13 Jul 2014 22:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-dates-conversion/m-p/177406#M264803</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-07-13T22:26:42Z</dc:date>
    </item>
  </channel>
</rss>

