<?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: Difference between two dates- Length of Stay (days) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441436#M282628</link>
    <description>&lt;P&gt;Hi please try this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates_again;
    set work.import;
    sas_admitdate=input(admitdate,mmddyy10.);
    sas_releasedate=input(releasedate,mmddyy10.);
    LOS=intck('day', sas_releasedate, sas_admitdate);
    put los;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 02 Mar 2018 00:48:45 GMT</pubDate>
    <dc:creator>Miracle</dc:creator>
    <dc:date>2018-03-02T00:48:45Z</dc:date>
    <item>
      <title>Difference between two dates- Length of Stay (days)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441421#M282626</link>
      <description>&lt;P&gt;Hi there!&lt;BR /&gt;Stuck on a problem-- I need to determine the length of stay (in days) between two dates (formatted (mmddyyyy) in my dataset: ex. 01/22/2015). Here's my code:&lt;/P&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;data dates_again;&lt;BR /&gt;set work.import;&lt;BR /&gt;admitdate=input(mmddyyyy10.);&lt;BR /&gt;releasedate=input(mmddyyyy10.);&lt;BR /&gt;LOS=intck('dd', releasedate, admitdate);&lt;BR /&gt;put los;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get an error message for admitdate and releasedate, "Expecting an arithmetic expression":&lt;/P&gt;&lt;DIV class="sasSource"&gt;64 admitdate=input(mmddyyyy10.);&lt;/DIV&gt;&lt;DIV class="sasError"&gt;___________&lt;/DIV&gt;&lt;DIV class="sasError"&gt;386&lt;/DIV&gt;&lt;DIV class="sasError"&gt;76&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;65 releasedate=input(mmddyyyy10.);&lt;/DIV&gt;&lt;DIV class="sasError"&gt;___________&lt;/DIV&gt;&lt;DIV class="sasError"&gt;386&lt;/DIV&gt;&lt;DIV class="sasError"&gt;76&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 386-185: Expecting an arithmetic expression.&lt;/DIV&gt;&lt;PRE class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; Help! Not sure what else to do.&lt;BR /&gt;&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 23:18:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441421#M282626</guid>
      <dc:creator>alyxm</dc:creator>
      <dc:date>2018-03-01T23:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates- Length of Stay (days)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441435#M282627</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;admitdate=input(mmddyy10.); [ the format only has 2 ys] to actually input would require either a character variable name&lt;/P&gt;
&lt;P&gt;admitdate=input(datechar, mmddyy10.); or a date literal string&lt;/P&gt;
&lt;P&gt;admitdate=input('02/15/2018', mmddyy10.);&lt;/P&gt;
&lt;P&gt;Since "input" didn't work then SAS is expecting an "arithemetic expression";&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are your variables admitdate and releasedate character or numeric. Please run proc contents on the set an determine which.&lt;/P&gt;
&lt;P&gt;It may be that your variable is numeric with an existing SAS format of mmddyy10 and no conversion is needed or desired.&lt;/P&gt;
&lt;P&gt;If the variables are indeed character then you would need to use input but the target variable name must be a different variable:&lt;/P&gt;
&lt;P&gt;admitdatenum = input(admitdate, mmddyy10.) and similar for the releasedate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LOS= releasedatenum - admitdatenum +1;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or&lt;/P&gt;
&lt;P&gt;LOS=intck('day',&amp;nbsp; admitdatenum, releasedatenum) +1;&lt;/P&gt;
&lt;P&gt;the +1 is to include both ends. If released on the date of admission otherwise you get 0.&lt;/P&gt;
&lt;P&gt;Using intck you would get a negative value with the admitdate after releasedate. DD is not a valid interval for intck.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 00:48:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441435#M282627</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-02T00:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates- Length of Stay (days)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441436#M282628</link>
      <description>&lt;P&gt;Hi please try this&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates_again;
    set work.import;
    sas_admitdate=input(admitdate,mmddyy10.);
    sas_releasedate=input(releasedate,mmddyy10.);
    LOS=intck('day', sas_releasedate, sas_admitdate);
    put los;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Mar 2018 00:48:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441436#M282628</guid>
      <dc:creator>Miracle</dc:creator>
      <dc:date>2018-03-02T00:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates- Length of Stay (days)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441458#M282629</link>
      <description>&lt;P&gt;This worked! Thanks so much! I also had to add "+1" at the end of the LOS row to include both the actual admission date and the release date.&lt;BR /&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 04:48:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441458#M282629</guid>
      <dc:creator>alyxm</dc:creator>
      <dc:date>2018-03-02T04:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Difference between two dates- Length of Stay (days)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441462#M282630</link>
      <description>Thanks for responding! Actually, my variables for admitdate and releasedate are numeric, so I actually did not have to convert to SAS format of mmddyy10. Thanks again!</description>
      <pubDate>Fri, 02 Mar 2018 05:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Difference-between-two-dates-Length-of-Stay-days/m-p/441462#M282630</guid>
      <dc:creator>alyxm</dc:creator>
      <dc:date>2018-03-02T05:06:36Z</dc:date>
    </item>
  </channel>
</rss>

