<?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: rounding up dates with rounding unit in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659009#M22682</link>
    <description>Thanks very much for the prompt reply and an effective solution!</description>
    <pubDate>Mon, 15 Jun 2020 14:23:18 GMT</pubDate>
    <dc:creator>elolvido</dc:creator>
    <dc:date>2020-06-15T14:23:18Z</dc:date>
    <item>
      <title>rounding up dates with rounding unit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659001#M22679</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm fairly new to SAS coming from R and am adapting someone else's previous code for my project.&amp;nbsp; In a large dataset with dates, we must round the date to the nearest quarter, which was previously done as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data xyz;
set xyz;
date_rounded=round(date,90);
format date_rounded DATE11.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This works great, and I want to do the exact same thing, but only allowing upwards rounding (so if they are even a couple days into quarter 2, it will be rounded to quarter 3's date).&amp;nbsp; I don't see an obvious way to do this since the CEIL function doesn't allow for a second argument specifying the rounding unit.&amp;nbsp; However, this dataset is massive and covers over 15 years, so rather than macgyvering a clumsy solution using my limited SAS, I am hoping there is a simple/efficient way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you have any suggestions!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 14:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659001#M22679</guid>
      <dc:creator>elolvido</dc:creator>
      <dc:date>2020-06-15T14:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up dates with rounding unit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659005#M22680</link>
      <description>&lt;P&gt;This is done with the&amp;nbsp;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p10v3sa3i4kfxfn1sovhi5xzxh8n.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;INTNX()&lt;/A&gt;&amp;nbsp;function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date_rounded = intnx('quarter',date,0,'e');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which gives you the correct calendar end date for the quarter.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 14:15:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659005#M22680</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-15T14:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up dates with rounding unit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659008#M22681</link>
      <description>&lt;P&gt;The question is what result you actually want as you don't say.&lt;/P&gt;
&lt;P&gt;The proper function would likely be the INTNX function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result= intnx('quarter', datevariable,0,'B')&amp;nbsp; would provide the first day (begining) of the calendar quarter the date occurs in.&lt;/P&gt;
&lt;P&gt;Result= intnx('quarter',datevaraible,0,'E') would provide the last day (end) of the calendar quarter the date occurs in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Result = intnx('quarter',datevaraible, 1,'B') would provide the first day of the next calendar quarter. I think this might be the one you want but provided the others just in case.&lt;/P&gt;
&lt;P&gt;If your variable is actually a datetime you would use DTQUARTER instead. It is amazing how many people do not differentiate between "date" and "datetime" values.&lt;/P&gt;
&lt;P&gt;Reason to use INTNX is that it will account for possibly issues with leap days.&lt;/P&gt;
&lt;P&gt;And the companion function INTCK returns number of intervals between to dates, time or datetime values.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jun 2020 14:20:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659008#M22681</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-15T14:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up dates with rounding unit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659009#M22682</link>
      <description>Thanks very much for the prompt reply and an effective solution!</description>
      <pubDate>Mon, 15 Jun 2020 14:23:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659009#M22682</guid>
      <dc:creator>elolvido</dc:creator>
      <dc:date>2020-06-15T14:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: rounding up dates with rounding unit</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659010#M22683</link>
      <description>Ah yes, it is the end date I am rounding up to. Variable is a date not a datetime. Thanks very much for the solution and breakdown!</description>
      <pubDate>Mon, 15 Jun 2020 14:24:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rounding-up-dates-with-rounding-unit/m-p/659010#M22683</guid>
      <dc:creator>elolvido</dc:creator>
      <dc:date>2020-06-15T14:24:20Z</dc:date>
    </item>
  </channel>
</rss>

