<?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: Looking to find difference between Admin and Discharge dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752456#M237034</link>
    <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/383273"&gt;@PilOSU&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/383273"&gt;@PilOSU&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have one date that's on the leap day in 2016. Do you know how would i account for that?&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151645"&gt;@JOL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could simplify the format to operate on plain month numbers (1, 2, ..., 12) and then apply it to &lt;FONT face="courier new,courier"&gt;month(datepart(&lt;EM&gt;your_datetime_value&lt;/EM&gt;))&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Or use existing SAS &lt;EM&gt;functions&lt;/EM&gt; instead of a user-defined format to get from the month number to the appropriate range of months:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
have='29FEB2016:12:34:56'dt; /* arbitrary datetime value */
length want $7;
want=choosec(mod((month(datepart(have))+9)/3,4)+1,
             'Mar-May','Jun-Aug','Sep-Nov','Dec-Feb');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jul 2021 22:33:31 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2021-07-06T22:33:31Z</dc:date>
    <item>
      <title>Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752356#M236974</link>
      <description>&lt;P&gt;I have data for admin and discharge dates. They are both numeric values, with formats of DATETIME and the informat ANYDTDTM40.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to characterize the months of each observation into four categories, (March-May, June-August, September-November, December-February) and put it into a proc tabulate table that i have already made. Can anyone point me in the right direction of what code to look at?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 16:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752356#M236974</guid>
      <dc:creator>PilOSU</dc:creator>
      <dc:date>2021-07-06T16:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752379#M236989</link>
      <description>&lt;P&gt;One method is to create a custom format using Proc Format and apply the custom format in your Proc Tabulate code;&amp;nbsp; See sample code below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;BR /&gt;value dtm "01MAR2021:00:00:00"DT - "31MAY2021:00:00:00"DT = "March-May"&lt;BR /&gt;"01JUN2021:00:00:00"DT - "31AUG2021:00:00:00"DT = "June-August"&lt;BR /&gt;"01SEP2021:00:00:00"DT - "30NOV2021:00:00:00"DT = "September-November"&lt;BR /&gt;"01DEC2021:00:00:00"DT - "28FEB2022:00:00:00"DT = "December-February";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data test;&lt;BR /&gt;admin= "25MAR2021:00:00:00"DT;&lt;BR /&gt;discharge = "18nov2021:00:00:00"DT;&lt;BR /&gt;format admin discharge dtm.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc tabulate data=test format=dtm.;&lt;BR /&gt;var admin discharge;&lt;BR /&gt;table admin discharge;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 18:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752379#M236989</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2021-07-06T18:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752389#M236997</link>
      <description>&lt;P&gt;My dates span many different years from 2006 to 2021, is there a way to change the code to express this, because it with the code supplied it just returns the values in my dataset.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 19:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752389#M236997</guid>
      <dc:creator>PilOSU</dc:creator>
      <dc:date>2021-07-06T19:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752401#M237000</link>
      <description>&lt;P&gt;Automated the code with macro variables to produce custom format for the range of dates you specified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro dtmm;&lt;BR /&gt;proc format;&lt;BR /&gt;value dtm &lt;BR /&gt;%do i=2006 %to 2021;&lt;BR /&gt;"01MAR&amp;amp;i.:00:00:00"DT - "31MAY&amp;amp;i.:00:00:00"DT = "March-May"&lt;BR /&gt;"01JUN&amp;amp;i.:00:00:00"DT - "31AUG&amp;amp;i.:00:00:00"DT = "June-August"&lt;BR /&gt;"01SEP&amp;amp;i.:00:00:00"DT - "30NOV&amp;amp;i.:00:00:00"DT = "September-November"&lt;BR /&gt;"01DEC&amp;amp;i.:00:00:00"DT - "28FEB%eval(&amp;amp;i+1):00:00:00"DT = "December-February"&lt;BR /&gt;%end;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;%mend dtmm;&lt;BR /&gt;%dtmm&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 19:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752401#M237000</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2021-07-06T19:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752405#M237003</link>
      <description>so that is what macros can do... Thank you!</description>
      <pubDate>Tue, 06 Jul 2021 20:23:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752405#M237003</guid>
      <dc:creator>PilOSU</dc:creator>
      <dc:date>2021-07-06T20:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752413#M237008</link>
      <description>&lt;P&gt;I have one date that's on the leap day in 2016. Do you know how would i account for that?&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151645"&gt;@JOL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 20:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752413#M237008</guid>
      <dc:creator>PilOSU</dc:creator>
      <dc:date>2021-07-06T20:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752456#M237034</link>
      <description>&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/383273"&gt;@PilOSU&lt;/a&gt;,&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/383273"&gt;@PilOSU&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have one date that's on the leap day in 2016. Do you know how would i account for that?&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/151645"&gt;@JOL&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You could simplify the format to operate on plain month numbers (1, 2, ..., 12) and then apply it to &lt;FONT face="courier new,courier"&gt;month(datepart(&lt;EM&gt;your_datetime_value&lt;/EM&gt;))&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Or use existing SAS &lt;EM&gt;functions&lt;/EM&gt; instead of a user-defined format to get from the month number to the appropriate range of months:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
have='29FEB2016:12:34:56'dt; /* arbitrary datetime value */
length want $7;
want=choosec(mod((month(datepart(have))+9)/3,4)+1,
             'Mar-May','Jun-Aug','Sep-Nov','Dec-Feb');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 22:33:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752456#M237034</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-07-06T22:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: Looking to find difference between Admin and Discharge dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752555#M237083</link>
      <description>&lt;P&gt;2016 was not a leap year so you may have a typo in the data.&amp;nbsp; I modified the macro to account for leap years between 2004 to 2024.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro dtmm;&lt;BR /&gt;proc format;&lt;BR /&gt;value dtm &lt;BR /&gt;%do i=2006 %to 2021;&lt;BR /&gt;"01MAR&amp;amp;i.:00:00:00"DT - "31MAY&amp;amp;i.:00:00:00"DT = "March-May"&lt;BR /&gt;"01JUN&amp;amp;i.:00:00:00"DT - "31AUG&amp;amp;i.:00:00:00"DT = "June-August"&lt;BR /&gt;"01SEP&amp;amp;i.:00:00:00"DT - "30NOV&amp;amp;i.:00:00:00"DT = "September-November"&lt;BR /&gt;"01DEC&amp;amp;i.:00:00:00"DT - "28FEB%eval(&amp;amp;i+1):00:00:00"DT = "December-February"&lt;BR /&gt;&lt;BR /&gt;%end;&lt;BR /&gt;%do i=2004 %to 2024 %by 4;&lt;BR /&gt;"29FEB&amp;amp;i.:00:00:00"DT = "December-February"&lt;BR /&gt;%end;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;%mend dtmm;&lt;BR /&gt;%dtmm&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jul 2021 13:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looking-to-find-difference-between-Admin-and-Discharge-dates/m-p/752555#M237083</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2021-07-07T13:16:02Z</dc:date>
    </item>
  </channel>
</rss>

