<?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: Changing Date values to a new date value in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604580#M17113</link>
    <description>&lt;P&gt;So you appear from the photographs of your data (pictures of data is better than no data, but text is much much better) your variable is not a DATE.&amp;nbsp; It is a DATETIME.&amp;nbsp; &amp;nbsp;And you have not set the end of the month to the actual end of the month, but to the start of the last day of the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It will probably be a lot easier to force the END to the START instead of the other way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start_dt = intnx('dtmonth',end_dt,0,'b');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To replicate that start of the last day of the month format you would need a little more logic. A couple of examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;end_dt = intnx('dtday',intnx('dtmonth',start_dt,0,'e'),0,'b');
end_dt = dhms(intnx('month',datepart(start_dt),0,'b'),0,0,0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It might help to first convert your variables so that they contain actual DATE values instead of DATETIME values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start_date = datepart(start_dt);
end_date=datepart(end_dt);
format start_date end_date date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then either conversion is just as easy.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start_date = intnx('month',end_date,0,'b');
end_date   = intnx('month',start_date,0,'e');&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 15 Nov 2019 18:36:14 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-15T18:36:14Z</dc:date>
    <item>
      <title>Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604566#M17102</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm working with two different tables - one table has the dates of each month listed as the LAST day of the month (example: 31JAN2019), however my other table has the dates as the FIRST day of the month (example: 01JAN2019).&lt;/P&gt;&lt;P&gt;What I would like to do is change the dates that are the first day of the month to match the last day of the month.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I included a screen shot, I'm new to SAS so obviously this is wrong - it's not working.&amp;nbsp; another thing is I would like my MONTH_LAST_DAY to be a date and right now it's coming out as #.&lt;/P&gt;&lt;P&gt;Or perhaps they's a last day of month format I'm not aware of that would work better??&lt;/P&gt;&lt;P&gt;Thank you for your help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS example.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34010iB78487AE7211B195/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS example.jpg" alt="SAS example.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 17:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604566#M17102</guid>
      <dc:creator>LRogers</dc:creator>
      <dc:date>2019-11-15T17:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604568#M17104</link>
      <description>&lt;P&gt;&lt;EM&gt;Methinks &lt;/EM&gt;All you need is&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_last_day=intnx('dtmon',month_first_day,0,'e');
format month_last_day datetime20.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:11:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604568#M17104</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-15T18:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604572#M17107</link>
      <description>&lt;P&gt;Thank you!!!&lt;/P&gt;&lt;P&gt;When i ran that code I get numbers as my date....I'm assuming I would need to add a date format to the code?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS2.jpg" style="width: 545px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34011i67699DEA869CEFF8/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS2.jpg" alt="SAS2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604572#M17107</guid>
      <dc:creator>LRogers</dc:creator>
      <dc:date>2019-11-15T18:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604573#M17108</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/281120"&gt;@LRogers&lt;/a&gt;&amp;nbsp; &amp;nbsp;yes, sorry I edited the previous adding a a datetime format. Here again&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_last_day=intnx('dtmon',month_first_day,0,'e');
format month_last_day datetime20.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604573#M17108</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-15T18:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604575#M17109</link>
      <description>&lt;P&gt;That worked great!&amp;nbsp; Thanks again!&lt;/P&gt;&lt;P&gt;One last question...Is there a way to make the time be zeros (00:00:00)?&amp;nbsp; That is how the date/time is like in the other table as well....just trying to get them to match.&amp;nbsp; Thank you!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS3.jpg" style="width: 422px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34012i48B7FD40F978496D/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS3.jpg" alt="SAS3.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604575#M17109</guid>
      <dc:creator>LRogers</dc:creator>
      <dc:date>2019-11-15T18:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604577#M17110</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_last_day=intnx('dtmon',month_first_day,0,'e')-86399;
format month_last_day datetime20.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:31:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604577#M17110</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-15T18:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604578#M17111</link>
      <description>&lt;P&gt;Wow!!!&amp;nbsp; thank you!&amp;nbsp; You were so helpful!&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate it!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:33:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604578#M17111</guid>
      <dc:creator>LRogers</dc:creator>
      <dc:date>2019-11-15T18:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604579#M17112</link>
      <description>&lt;P&gt;Most welcome. Have a good one! Cheers!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604579#M17112</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-15T18:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604580#M17113</link>
      <description>&lt;P&gt;So you appear from the photographs of your data (pictures of data is better than no data, but text is much much better) your variable is not a DATE.&amp;nbsp; It is a DATETIME.&amp;nbsp; &amp;nbsp;And you have not set the end of the month to the actual end of the month, but to the start of the last day of the month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It will probably be a lot easier to force the END to the START instead of the other way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start_dt = intnx('dtmonth',end_dt,0,'b');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To replicate that start of the last day of the month format you would need a little more logic. A couple of examples:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;end_dt = intnx('dtday',intnx('dtmonth',start_dt,0,'e'),0,'b');
end_dt = dhms(intnx('month',datepart(start_dt),0,'b'),0,0,0);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It might help to first convert your variables so that they contain actual DATE values instead of DATETIME values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start_date = datepart(start_dt);
end_date=datepart(end_dt);
format start_date end_date date9.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then either conversion is just as easy.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;start_date = intnx('month',end_date,0,'b');
end_date   = intnx('month',start_date,0,'e');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604580#M17113</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T18:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604583#M17115</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month_last_day=intnx('dtmon',month_first_day,0,'e')-86399;
format month_last_day datetime20.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why use the "magic" number? What the heck is 86399?&lt;/P&gt;
&lt;P&gt;Did you mean '23:59:59't ?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604583#M17115</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-15T18:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Changing Date values to a new date value</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604585#M17116</link>
      <description>&lt;P&gt;Lol Sir&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp; I never ever imagined you would open your sense of humor. I just fancied a direct subtraction from the &lt;EM&gt;end&lt;/EM&gt; &lt;EM&gt;seconds&lt;/EM&gt; value unlike the nested function. However, I was anticipating you would chime in with more eloquent and&amp;nbsp; detailed explanation and that you did. I have been taking notes of all your help that has benefited me and others across the sas world &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you as always &lt;U&gt;for your generosity!&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2019 18:51:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Changing-Date-values-to-a-new-date-value/m-p/604585#M17116</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-11-15T18:51:22Z</dc:date>
    </item>
  </channel>
</rss>

