<?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: Dynamically Finding the 28th of Each Month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726577#M225784</link>
    <description>&lt;P&gt;Which macro variables do you need to change?&lt;BR /&gt;What do you need them to change to?&lt;BR /&gt;Have you looked at the "S" option for alignment of parameter?&lt;BR /&gt;You're aware you can add 27 to the start of a month to get the 28th date?&lt;BR /&gt;Want the 28th for the previous month? That would be the start of the previous month + 27.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data params;

start_date = '01May2021'd;


*run_date = today();
run_date = start_date;

beginmonth=intnx('month',run_date,-2, "B");
endingmonth=intnx('month',run_date,-1, "B");
rep_start_date=put(beginmonth+27, mmddyy10.);
rep_end_date=put(endingmonth+27, mmddyy10.);


run;

proc print data=params;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE class="table" aria-label="Data Set WORK.PARAMS"&gt;&lt;CAPTION aria-label="Data Set WORK.PARAMS"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;start_date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;run_date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;beginmonth&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;endingmonth&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;rep_start_date&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;rep_end_date&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;22401&lt;/TD&gt;
&lt;TD class="r data"&gt;22401&lt;/TD&gt;
&lt;TD class="r data"&gt;22340&lt;/TD&gt;
&lt;TD class="r data"&gt;22371&lt;/TD&gt;
&lt;TD class="data"&gt;03/28/2021&lt;/TD&gt;
&lt;TD class="data"&gt;04/28/2021&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3264"&gt;@Jeff_DOC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Good afternoon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate any help someone could offer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I need to have an older program run for data for the 28th day of each month on the first of the subsequent month. So on May 1 the beginmonth variable needs to allow me to run for data from March 28th to April 28th. I can do the report programming piece but what I can't get correct is to shift the date each month to the correct 28th day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the old section that will create the variables as they were before. I need to change these to find the 28th of each month, not the beginning or end of the time period as shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data params;&lt;BR /&gt;attrib &lt;BR /&gt;run_date length=8 format = mmddyy10.&lt;BR /&gt;beginmonth length=8 format = mmddyy10.&lt;BR /&gt;endingmonth length=8 format = mmddyy10. &lt;BR /&gt;rep_start_date length=$10&lt;BR /&gt;rep_end_date length=$10;&lt;/P&gt;
&lt;P&gt;today = put(date(),worddate18.);&lt;/P&gt;
&lt;P&gt;run_date = today();&lt;BR /&gt;beginmonth=intnx('month',run_date,-2, "BEGIN");&lt;BR /&gt;endingmonth=intnx('month',run_date,-1, "END");&lt;BR /&gt;rep_start_date=put(beginmonth, mmddyy10.);&lt;BR /&gt;rep_end_date=put(endingmonth, mmddyy10.);&lt;/P&gt;
&lt;P&gt;call symput("run_date",run_date);&lt;BR /&gt;call symput("beginmonth",beginmonth);&lt;BR /&gt;call symput("endingmonth",endingmonth);&lt;BR /&gt;call symput("rep_start_date",rep_start_date);&lt;BR /&gt;call symput("rep_end_date",rep_end_date);&lt;BR /&gt;call symput('today',today);&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Mar 2021 22:55:17 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-03-15T22:55:17Z</dc:date>
    <item>
      <title>Dynamically Finding the 28th of Each Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726570#M225779</link>
      <description>&lt;P&gt;Good afternoon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate any help someone could offer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I need to have an older program run for data for the 28th day of each month on the first of the subsequent month. So on May 1 the beginmonth variable needs to allow me to run for data from March 28th to April 28th. I can do the report programming piece but what I can't get correct is to shift the date each month to the correct 28th day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the old section that will create the variables as they were before. I need to change these to find the 28th of each month, not the beginning or end of the time period as shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data params;&lt;BR /&gt;attrib &lt;BR /&gt;run_date length=8 format = mmddyy10.&lt;BR /&gt;beginmonth length=8 format = mmddyy10.&lt;BR /&gt;endingmonth length=8 format = mmddyy10. &lt;BR /&gt;rep_start_date length=$10&lt;BR /&gt;rep_end_date length=$10;&lt;/P&gt;
&lt;P&gt;today = put(date(),worddate18.);&lt;/P&gt;
&lt;P&gt;run_date = today();&lt;BR /&gt;beginmonth=intnx('month',run_date,-2, "BEGIN");&lt;BR /&gt;endingmonth=intnx('month',run_date,-1, "END");&lt;BR /&gt;rep_start_date=put(beginmonth, mmddyy10.);&lt;BR /&gt;rep_end_date=put(endingmonth, mmddyy10.);&lt;/P&gt;
&lt;P&gt;call symput("run_date",run_date);&lt;BR /&gt;call symput("beginmonth",beginmonth);&lt;BR /&gt;call symput("endingmonth",endingmonth);&lt;BR /&gt;call symput("rep_start_date",rep_start_date);&lt;BR /&gt;call symput("rep_end_date",rep_end_date);&lt;BR /&gt;call symput('today',today);&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 22:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726570#M225779</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2021-03-15T22:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically Finding the 28th of Each Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726573#M225781</link>
      <description>&lt;P&gt;Here's one way to find the 28th of the month preceding any date:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data example;
   date = today();
   prior28 = intnx('month',date,-1,'B') + 27;
   put date= date9. prior28= date9.;
run;&lt;/PRE&gt;
&lt;P&gt;The B is the beginning so add 27 to get to 28 since date values are integer numbers of days.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 22:43:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726573#M225781</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-15T22:43:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically Finding the 28th of Each Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726577#M225784</link>
      <description>&lt;P&gt;Which macro variables do you need to change?&lt;BR /&gt;What do you need them to change to?&lt;BR /&gt;Have you looked at the "S" option for alignment of parameter?&lt;BR /&gt;You're aware you can add 27 to the start of a month to get the 28th date?&lt;BR /&gt;Want the 28th for the previous month? That would be the start of the previous month + 27.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data params;

start_date = '01May2021'd;


*run_date = today();
run_date = start_date;

beginmonth=intnx('month',run_date,-2, "B");
endingmonth=intnx('month',run_date,-1, "B");
rep_start_date=put(beginmonth+27, mmddyy10.);
rep_end_date=put(endingmonth+27, mmddyy10.);


run;

proc print data=params;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;TABLE class="table" aria-label="Data Set WORK.PARAMS"&gt;&lt;CAPTION aria-label="Data Set WORK.PARAMS"&gt;&amp;nbsp;&lt;/CAPTION&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;&lt;COLGROUP&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;Obs&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;start_date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;run_date&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;beginmonth&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;endingmonth&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;rep_start_date&lt;/TH&gt;
&lt;TH class="header" scope="col"&gt;rep_end_date&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TH class="r rowheader" scope="row"&gt;1&lt;/TH&gt;
&lt;TD class="r data"&gt;22401&lt;/TD&gt;
&lt;TD class="r data"&gt;22401&lt;/TD&gt;
&lt;TD class="r data"&gt;22340&lt;/TD&gt;
&lt;TD class="r data"&gt;22371&lt;/TD&gt;
&lt;TD class="data"&gt;03/28/2021&lt;/TD&gt;
&lt;TD class="data"&gt;04/28/2021&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/3264"&gt;@Jeff_DOC&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Good afternoon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would appreciate any help someone could offer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically I need to have an older program run for data for the 28th day of each month on the first of the subsequent month. So on May 1 the beginmonth variable needs to allow me to run for data from March 28th to April 28th. I can do the report programming piece but what I can't get correct is to shift the date each month to the correct 28th day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the old section that will create the variables as they were before. I need to change these to find the 28th of each month, not the beginning or end of the time period as shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data params;&lt;BR /&gt;attrib &lt;BR /&gt;run_date length=8 format = mmddyy10.&lt;BR /&gt;beginmonth length=8 format = mmddyy10.&lt;BR /&gt;endingmonth length=8 format = mmddyy10. &lt;BR /&gt;rep_start_date length=$10&lt;BR /&gt;rep_end_date length=$10;&lt;/P&gt;
&lt;P&gt;today = put(date(),worddate18.);&lt;/P&gt;
&lt;P&gt;run_date = today();&lt;BR /&gt;beginmonth=intnx('month',run_date,-2, "BEGIN");&lt;BR /&gt;endingmonth=intnx('month',run_date,-1, "END");&lt;BR /&gt;rep_start_date=put(beginmonth, mmddyy10.);&lt;BR /&gt;rep_end_date=put(endingmonth, mmddyy10.);&lt;/P&gt;
&lt;P&gt;call symput("run_date",run_date);&lt;BR /&gt;call symput("beginmonth",beginmonth);&lt;BR /&gt;call symput("endingmonth",endingmonth);&lt;BR /&gt;call symput("rep_start_date",rep_start_date);&lt;BR /&gt;call symput("rep_end_date",rep_end_date);&lt;BR /&gt;call symput('today',today);&lt;BR /&gt;run;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 22:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726577#M225784</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-03-15T22:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically Finding the 28th of Each Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726589#M225790</link>
      <description>&lt;P&gt;Since you both gave me a correct answer I flipped a coin (yes, I'm old enough to still carry coins) and Ballardw won!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks to you both for being willing to help!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 23:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726589#M225790</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2021-03-15T23:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically Finding the 28th of Each Month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726591#M225791</link>
      <description>&lt;P&gt;Since you both gave me a correct answer I flipped a coin (yes, I'm old enough to still carry coins) and Ballardw won!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for being willing to help!&lt;/P&gt;</description>
      <pubDate>Mon, 15 Mar 2021 23:31:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamically-Finding-the-28th-of-Each-Month/m-p/726591#M225791</guid>
      <dc:creator>Jeff_DOC</dc:creator>
      <dc:date>2021-03-15T23:31:05Z</dc:date>
    </item>
  </channel>
</rss>

