<?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: automatically find previous month and a year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353859#M82653</link>
    <description>&lt;P&gt;I would not use SYSfunc as the result is going to be ugly. Just as in your other post &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/auto-dates/m-p/353496#M82521" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/auto-dates/m-p/353496#M82521&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The intnx function as used in the other post works given any date. If you need previous from today then the base date in the function can be the function Today().&lt;/P&gt;
&lt;P&gt;The use the function Year or Month on the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx('P_Month', month(intnx('month',today(),-1));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;does what you are requesting. Year is left as an exercise for the interested reader.&lt;/P&gt;
&lt;P&gt;Note that you will have to nest at least 3 levels of %sysfunc to accomplisth the same thing, one for each function called: month, intnx, today. The resulting code with all of the extra () and such is harder to read and more likely to be fragile.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Apr 2017 19:32:32 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-04-26T19:32:32Z</dc:date>
    <item>
      <title>automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353838#M82647</link>
      <description>&lt;P&gt;Hi, I have a program&amp;nbsp;that uses hardcoded values.. something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let P_month = 03;&lt;BR /&gt;%let P_year = 2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where P_month is a previous month and P_year is the year associated to the previous month.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can you please advise how to automatically convert it using&amp;nbsp;sysfunc&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 18:26:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353838#M82647</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-04-26T18:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353853#M82650</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't fully understand what you want. I'm assuming&amp;nbsp; you have a current month and year and you want to know what they are if you shift one month back? This example uses January so you can see that it shifts to December of the previous year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let C_month = 01;
%let C_year = 2017;

%let P_month = %sysfunc(month(%sysfunc(intnx(month, %sysfunc(mdy(&amp;amp;c_month, 1, &amp;amp;c_year)), -1))));
%let P_year = %sysfunc(year(%sysfunc(intnx(month, %sysfunc(mdy(&amp;amp;c_month, 1, &amp;amp;c_year)), -1))));
%put The Current Month and Year are: &amp;amp;c_month, &amp;amp;c_year;
%put The Previous Month and Year (based on one month back) are: &amp;amp;p_month, &amp;amp;p_year;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2017 19:22:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353853#M82650</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-26T19:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353859#M82653</link>
      <description>&lt;P&gt;I would not use SYSfunc as the result is going to be ugly. Just as in your other post &lt;A href="https://communities.sas.com/t5/Base-SAS-Programming/auto-dates/m-p/353496#M82521" target="_blank"&gt;https://communities.sas.com/t5/Base-SAS-Programming/auto-dates/m-p/353496#M82521&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The intnx function as used in the other post works given any date. If you need previous from today then the base date in the function can be the function Today().&lt;/P&gt;
&lt;P&gt;The use the function Year or Month on the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; call symputx('P_Month', month(intnx('month',today(),-1));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;does what you are requesting. Year is left as an exercise for the interested reader.&lt;/P&gt;
&lt;P&gt;Note that you will have to nest at least 3 levels of %sysfunc to accomplisth the same thing, one for each function called: month, intnx, today. The resulting code with all of the extra () and such is harder to read and more likely to be fragile.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 19:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353859#M82653</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-26T19:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353880#M82664</link>
      <description>&lt;P&gt;collinelliot, thanks for your assistance. let me clearify&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;we run monthly reports&amp;nbsp;(usually, 2nd day of the month) covering&amp;nbsp;the previous month. Reports are working fine when we use set valus such as, so for Jan report (we will run the report on Feb 2nd) and values will be set as follows&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let p_month = 01;&lt;BR /&gt;%let p_year = 2017;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;on March 2nd will change the values as follows before running the reports&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let &lt;/SPAN&gt;&lt;SPAN&gt;p_&lt;/SPAN&gt;&lt;SPAN&gt;month = 02;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;%let p_year = 2017;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;can you please modify your code to take systems date and do it automatically... something like this&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%let P_month = %sysfunc(month(%sysfunc(intnx(month, %sysfunc(mdy(&lt;STRONG&gt;TODAY_MONTH&lt;/STRONG&gt;, 1, &lt;STRONG&gt;TODAY_YEAR&lt;/STRONG&gt;)), -1))));&lt;BR /&gt;%let P_year = %sysfunc(year(%sysfunc(intnx(month, %sysfunc(mdy(&lt;STRONG&gt;TODAY_MONTH&lt;/STRONG&gt;, 1, &lt;STRONG&gt;TODAY_YEAR&lt;/STRONG&gt;))), -1))));&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks again for your assistance&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 20:28:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353880#M82664</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-04-26T20:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353883#M82666</link>
      <description>&lt;P&gt;I see. It's a matter of changing the mdy(..) to today()... But does it need to be done with %let / %sysfunc? I think&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;makes a good suggestion that would give you more legible code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That said:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let P_month = %sysfunc(month(%sysfunc(intnx(month, %sysfunc(today()), -1))));
%let P_year = %sysfunc(year(%sysfunc(intnx(month, %sysfunc(today()), -1))));
%put The Previous Month and Year (based on one month back) are: &amp;amp;p_month, &amp;amp;p_year;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2017 21:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353883#M82666</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-26T21:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353904#M82674</link>
      <description>&lt;P&gt;Here is what I've found... seems like my issue is with the format of the date (date1 and date2)... here are the 2 codes that I ran with the output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;----------ORIGINAL CODE with fixed values -------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;438 %let month = 03;&lt;BR /&gt;439 %let year = 2017;&lt;BR /&gt;440 %let date1 = '01Mar2017'd;&lt;BR /&gt;441 %let date2 = '01Apr2017'd;&lt;BR /&gt;444 %put &amp;amp;month, &amp;amp;year, &amp;amp;date1, &amp;amp;date2;&lt;BR /&gt;03, 2017, '01Mar2017'd, '01Apr2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;----------MODIFIED CODE to automatically select&amp;nbsp;values -------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;451 %let month =%sysfunc(intnx(month, %sysfunc(today()), -1), MONTH.);&lt;BR /&gt;452 %let year =%sysfunc(intnx(month, %sysfunc(today()), -1), YEAR.);&lt;BR /&gt;453&lt;BR /&gt;454 %let date1 =&lt;BR /&gt;454! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1)),date9.))%str(%')d;&lt;BR /&gt;455 %let date2 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),&lt;BR /&gt;455! 0)),date9.))%str(%')d;&lt;BR /&gt;457 %put &amp;amp;month, &amp;amp;year, &amp;amp;date1, &amp;amp;date2;&lt;BR /&gt;3, 2017, '01MAR2017'd, '01APR2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;----------Sample code -------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data.active;&lt;BR /&gt; set temp.v_table_all(keep = field1 field2 &lt;BR /&gt; where = (&amp;amp;date1 &amp;lt;= begindttm &amp;lt;&amp;amp;date2);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I run my code with the fixed values for date1 and date2, it works fine...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it is not working with&amp;nbsp;modified code. noticed that my modified code is returning month in upper caps and the fixed one is using lower caps. can that be an issue? and how to fix it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 21:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353904#M82674</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-04-26T21:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353907#M82675</link>
      <description>&lt;P&gt;Looking at what you're trying to do, I think the following at least comes close. your "begindttm" variable, though, makes me wonder if you have a date value or a datetime value that you're comparing to. If it's not date, you'll need to change a few things.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let cur_date = %sysfunc(today(), date9.);  &amp;lt;-- Or yes, doh, just &amp;amp;sysdate9...
%let pre_date = %sysfunc(putn(%sysfunc(intnx(month, %sysfunc(today()), -1, same)), date9.));

%put &amp;amp;cur_date;
%put &amp;amp;pre_date;

data data.active;
set temp.v_table_all(keep = field1 field2 
where = ("&amp;amp;pre_date"d &amp;lt;= begindttm &amp;lt; "&amp;amp;cur_date"d);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Apr 2017 21:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353907#M82675</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-04-26T21:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353908#M82676</link>
      <description>&lt;P&gt;No matter which way you end up going (DATA step, %SYSFUNC), I suggest you start with this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let refdate = "&amp;amp;sysdate9"d;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then build the month and year from &amp;amp;REFDATE.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why?&amp;nbsp; For practical purposes in running a monthly report, &amp;amp;SYSDATE9 and TODAY() give you the same day.&amp;nbsp; But consider what would happen if you ever want to backdate your report and get the report for 2 months ago instead of last month.&amp;nbsp; Now you only have to change one line of code, hard-coding a value in the %LET statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 21:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353908#M82676</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-04-26T21:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353918#M82682</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22922"&gt;@tparvaiz&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Here is what I've found... seems like my issue is with the format of the date (date1 and date2)... here are the 2 codes that I ran with the output&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;----------ORIGINAL CODE with fixed values -------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;438 %let month = 03;&lt;BR /&gt;439 %let year = 2017;&lt;BR /&gt;440 %let date1 = '01Mar2017'd;&lt;BR /&gt;441 %let date2 = '01Apr2017'd;&lt;BR /&gt;444 %put &amp;amp;month, &amp;amp;year, &amp;amp;date1, &amp;amp;date2;&lt;BR /&gt;03, 2017, '01Mar2017'd, '01Apr2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;----------MODIFIED CODE to automatically select&amp;nbsp;values -------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;451 %let month =%sysfunc(intnx(month, %sysfunc(today()), -1), MONTH.);&lt;BR /&gt;452 %let year =%sysfunc(intnx(month, %sysfunc(today()), -1), YEAR.);&lt;BR /&gt;453&lt;BR /&gt;454 %let date1 =&lt;BR /&gt;454! %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),-1)),date9.))%str(%')d;&lt;BR /&gt;455 %let date2 = %str(%')%sysfunc(putn(%sysfunc(intnx(month,%sysfunc(today()),&lt;BR /&gt;455! 0)),date9.))%str(%')d;&lt;BR /&gt;457 %put &amp;amp;month, &amp;amp;year, &amp;amp;date1, &amp;amp;date2;&lt;BR /&gt;3, 2017, '01MAR2017'd, '01APR2017'd&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;----------Sample code -------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data data.active;&lt;BR /&gt; set temp.v_table_all(keep = field1 field2 &lt;BR /&gt; where = (&amp;amp;date1 &amp;lt;= begindttm &amp;lt;&amp;amp;date2);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;when I run my code with the fixed values for date1 and date2, it works fine...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it is not working with&amp;nbsp;modified code. noticed that my modified code is returning month in upper caps and the fixed one is using lower caps. can that be an issue? and how to fix it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And did you tryit with the code suggested in the previous post such as:&lt;/P&gt;
&lt;PRE&gt;data _null_;
   call symputx('YYYMM',put(intnx('month',today(),-1),yymmn6.));
   call symputx('date1',intnx('month',today(),-1,'b'));
   call symputx('date2',intnx('month',today(),0,'b'));
run;&lt;/PRE&gt;
&lt;P&gt;Experience says that using quotes as part of macro variables often has issues, besides requiring ugly code to put them in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And for the show use of date1 and date2 you do not need the date literal form of the date. The numeric version show in the above data _null_ step should work just fine.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that your posted example data step will throw errors because of missing ) AND using where with a variable that does not appear on the KEEP portion of the datastep options. Try:&lt;/P&gt;
&lt;PRE&gt;data data.active;
   set temp.v_table_all(keep = field1 field2 begindttm
               where = (&amp;amp;date1 &amp;lt;= begindttm &amp;lt;&amp;amp;date2));
run;&lt;/PRE&gt;
&lt;P&gt;BUT there may be yet more fun, you are comparing dates to a variable named Begindttm. I am afraid that Begindttm may actually be a a DATETIME variable and if so nothing is likely to be selected as dates are measured in days and datetime in seconds. Please see:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
   x= '01JUN2017'd;
   y= '01Jun2017:10:12:25'dt;
   put 'X in days=' x ' and y in seconds=' y;
run;&lt;/PRE&gt;
&lt;P&gt;So if your begindttm is a datetime on or near 1 Mar 2017 then it will not be between the date values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 21:49:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353918#M82682</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-04-26T21:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: automatically find previous month and a year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353922#M82683</link>
      <description>&lt;P&gt;Thanks again everyone for the assistance&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2017 21:53:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/automatically-find-previous-month-and-a-year/m-p/353922#M82683</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-04-26T21:53:50Z</dc:date>
    </item>
  </channel>
</rss>

