<?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: SAS weekly dates for rolling six month in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405557#M98676</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a main input SAS dataset something like this&lt;BR /&gt;&lt;BR /&gt;Master_ID INTAKE_DATE Division No_Of_Stores Sales_amt&lt;BR /&gt;1 01-Feb-2017 Central 10 50&lt;BR /&gt;1 02-Feb-2017 Central 20 90&lt;BR /&gt;2 03-Apr-2017 Southern 40 65&lt;BR /&gt;2 17-Apr-2017 Southern 15 70&lt;BR /&gt;3 10-Apr-2017 Southern 17 50&lt;BR /&gt;3 08-May-2017 Northern 19 90&lt;BR /&gt;5 01-Jul-2017 Northern 29 65&lt;BR /&gt;7 17-Sep-2017 Eastern 39 70&lt;BR /&gt;7 30-Sep-2017 Eastern 99 70&lt;BR /&gt;&lt;BR /&gt;and I need all transactions which happend every starting of monday till end of sunday weekly basis in a month.&lt;BR /&gt;I want for rolling 6 months(from 1st april 2017 till 30th sep 2017). the output should be like this&lt;BR /&gt;&lt;BR /&gt;Monday Sunday Division Total_Stores Total_Sales_amt&lt;BR /&gt;03-Apr-2017 09-Apr-2017 Central 2 500&lt;BR /&gt;10-Apr-2017 16-Apr-2017 Southern 9 900&lt;BR /&gt;17-Apr-2017 23-Apr-2017 Northern 10 65&lt;BR /&gt;24-Apr-2017 30-Apr-2017 Eastern 15 70&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Ravi</description>
    <pubDate>Thu, 19 Oct 2017 14:27:09 GMT</pubDate>
    <dc:creator>Ravikumar_RT</dc:creator>
    <dc:date>2017-10-19T14:27:09Z</dc:date>
    <item>
      <title>SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405497#M98660</link>
      <description>&lt;P&gt;Hello ,&lt;BR /&gt;&lt;BR /&gt;Hope you all doing good.&lt;BR /&gt;&lt;BR /&gt;I need a help on weekly dates for my monthly reporting&lt;BR /&gt;&lt;BR /&gt;I need to identify week start date and end date and thats for every Monday to Sunday pattern,&lt;BR /&gt;&lt;BR /&gt;also its for rolling back 6 months to current reporting month&lt;BR /&gt;&lt;BR /&gt;example:-&lt;BR /&gt;&lt;BR /&gt;if report run is 1st November 2017, I need weekly start date and end date of every monday to sunday from 1st of April 2017 to 30th September 2017(6 months)&lt;BR /&gt;&lt;BR /&gt;I have a historical SAS dataset with ID, Intake_date and Amount columns and i need to report Intake date wise weekly sales for rolling six month on a monthly basis.&lt;BR /&gt;&lt;BR /&gt;Please suggest me with a sas code (it will be more helpful if any sas code automation suggestions).&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Ravi&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 12:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405497#M98660</guid>
      <dc:creator>Ravikumar_RT</dc:creator>
      <dc:date>2017-10-19T12:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405506#M98662</link>
      <description>&lt;P&gt;To cumulate values per week, create a normalized date variable by using the intnx function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;weekdate = intnx('week',intake_date,0,'b');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then use proc summary with by weekdate to get weekly values.&lt;/P&gt;
&lt;P&gt;A similar calculation can be done for months.&lt;/P&gt;
&lt;P&gt;Or you can calculate the weekdate that was 6 months ago and start your report from that.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 12:48:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405506#M98662</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-19T12:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405507#M98663</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
format startDate endDate date date9. day $1.;

keep date day;

reportDate='1Nov2017'd;

endDate=intnx("day",reportDate,-1);
startDate=intnx("month",reportDate,-6);

date=startDate;

do while (date&amp;lt;=endDate and i&amp;lt;400);
    i+1;

	day=" ";
	if weekday(date)=1 then day="M";
	if weekday(date)=7 then day="S";

	date=intnx("day",date,1);

	if day ne " " then output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Oct 2017 12:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405507#M98663</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-10-19T12:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405518#M98665</link>
      <description>Hi,&lt;BR /&gt;Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;Above code is giving results from sunday to next monday i.e 01OCT2017(Sunday) to 02OCT2017(Monday) however i need sunday to previous monday exmple:- 25SEP2017 to 01OCT2017.&lt;BR /&gt;&lt;BR /&gt;Please assist me.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Ravi&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Oct 2017 13:16:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405518#M98665</guid>
      <dc:creator>Ravikumar_RT</dc:creator>
      <dc:date>2017-10-19T13:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405525#M98667</link>
      <description>I'm not sure i understand what you're asking for. Can you provide an example for the desired output ?</description>
      <pubDate>Thu, 19 Oct 2017 13:23:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405525#M98667</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-10-19T13:23:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405527#M98668</link>
      <description>&lt;P&gt;... and some example data to work with. Use the macro provided in&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; to convert a dataset to a data step, if you don't want to (or can't yet) write the step yourself.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Oct 2017 13:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405527#M98668</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-19T13:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405557#M98676</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I have a main input SAS dataset something like this&lt;BR /&gt;&lt;BR /&gt;Master_ID INTAKE_DATE Division No_Of_Stores Sales_amt&lt;BR /&gt;1 01-Feb-2017 Central 10 50&lt;BR /&gt;1 02-Feb-2017 Central 20 90&lt;BR /&gt;2 03-Apr-2017 Southern 40 65&lt;BR /&gt;2 17-Apr-2017 Southern 15 70&lt;BR /&gt;3 10-Apr-2017 Southern 17 50&lt;BR /&gt;3 08-May-2017 Northern 19 90&lt;BR /&gt;5 01-Jul-2017 Northern 29 65&lt;BR /&gt;7 17-Sep-2017 Eastern 39 70&lt;BR /&gt;7 30-Sep-2017 Eastern 99 70&lt;BR /&gt;&lt;BR /&gt;and I need all transactions which happend every starting of monday till end of sunday weekly basis in a month.&lt;BR /&gt;I want for rolling 6 months(from 1st april 2017 till 30th sep 2017). the output should be like this&lt;BR /&gt;&lt;BR /&gt;Monday Sunday Division Total_Stores Total_Sales_amt&lt;BR /&gt;03-Apr-2017 09-Apr-2017 Central 2 500&lt;BR /&gt;10-Apr-2017 16-Apr-2017 Southern 9 900&lt;BR /&gt;17-Apr-2017 23-Apr-2017 Northern 10 65&lt;BR /&gt;24-Apr-2017 30-Apr-2017 Eastern 15 70&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Ravi</description>
      <pubDate>Thu, 19 Oct 2017 14:27:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405557#M98676</guid>
      <dc:creator>Ravikumar_RT</dc:creator>
      <dc:date>2017-10-19T14:27:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405899#M98773</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one in this community assist me with my below mentioed request please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 09:09:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405899#M98773</guid>
      <dc:creator>Ravikumar_RT</dc:creator>
      <dc:date>2017-10-20T09:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405902#M98774</link>
      <description>&lt;P&gt;Please supply data in a data step, as already requested. It's not rocket science.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 09:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405902#M98774</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-20T09:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS weekly dates for rolling six month</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405936#M98786</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have added just one small logic and it worked fine...:) here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want(rename = (date = Monday));&lt;BR /&gt;format startDate endDate date date9. day $1.;&lt;BR /&gt;&lt;BR /&gt;keep date Sunday;&lt;BR /&gt;&lt;BR /&gt;reportDate="&amp;amp;month_run."d;&lt;BR /&gt;&lt;BR /&gt;endDate=intnx("day",reportDate,-1);&lt;BR /&gt;startDate=intnx("month",reportDate,-6);&lt;BR /&gt;&lt;BR /&gt;date=startDate;&lt;BR /&gt;&lt;BR /&gt;do while (date&amp;lt;=endDate and i&amp;lt;400);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i+1;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;day=" ";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if weekday(date)=1 then day="M";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;date=intnx("day",date,1);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;if day ne " " then output;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Sunday = date+7;&lt;BR /&gt;end;&lt;BR /&gt;Format Sunday Date9.;&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;Thanks all for your inputs and helping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2017 13:08:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-weekly-dates-for-rolling-six-month/m-p/405936#M98786</guid>
      <dc:creator>Ravikumar_RT</dc:creator>
      <dc:date>2017-10-20T13:08:26Z</dc:date>
    </item>
  </channel>
</rss>

