<?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 Calculate number of week in accounting year based on number of week in calendar year in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959083#M374258</link>
    <description>&lt;P&gt;Hello to the team! I have created a table with all the dates from 01JAN1950 to 31DEC2100, which is used as a date dimension table in a dimensional model. I show here a simplified version of the table (I am using dates within 2025):&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;day_of_week_number&lt;/TD&gt;&lt;TD&gt;week_of_year_number&lt;/TD&gt;&lt;TD&gt;acc_week_of_year_number&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01JAN2025&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;02JAN2025&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;03JAN2025&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;04JAN2025&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;53&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;05JAN2025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&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATE: the date&lt;/P&gt;&lt;P&gt;DAY_OF_WEEK_NUMBER: the number of day in a week (1=Sunday, 7=Saturday)&lt;/P&gt;&lt;P&gt;WEEK_OF_YEAR_NUMBER: number of week in the calendar year&lt;/P&gt;&lt;P&gt;ACC_WEEK_OF_YEAR_NUMBER: number of week in the accounting year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not figured out yet how to calculate the accounting year week number. I suppose that I will have to create it based on the number of the week in the calendar year, which I do have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simplified code to create the table (the actual table has much more variables and observations):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data dim_date;
  do date='01jan2025'd to '31dec2025'd;
        day_of_week_number=weekday(date);
        week_of_year_number=week(date);
       /**** Here I need a statement to calculate 
              acc_week_of_year_number *******/
        output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does anyone have any idea on how to calculate that variable? Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 12 Feb 2025 17:22:33 GMT</pubDate>
    <dc:creator>mvalsamis</dc:creator>
    <dc:date>2025-02-12T17:22:33Z</dc:date>
    <item>
      <title>Calculate number of week in accounting year based on number of week in calendar year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959083#M374258</link>
      <description>&lt;P&gt;Hello to the team! I have created a table with all the dates from 01JAN1950 to 31DEC2100, which is used as a date dimension table in a dimensional model. I show here a simplified version of the table (I am using dates within 2025):&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&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TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;27DEC2025&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;51&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;28DEC2025&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;29DEC2025&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;30DEC2025&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31DEC2025&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;52&lt;/TD&gt;&lt;TD&gt;?&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATE: the date&lt;/P&gt;&lt;P&gt;DAY_OF_WEEK_NUMBER: the number of day in a week (1=Sunday, 7=Saturday)&lt;/P&gt;&lt;P&gt;WEEK_OF_YEAR_NUMBER: number of week in the calendar year&lt;/P&gt;&lt;P&gt;ACC_WEEK_OF_YEAR_NUMBER: number of week in the accounting year.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not figured out yet how to calculate the accounting year week number. I suppose that I will have to create it based on the number of the week in the calendar year, which I do have.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a simplified code to create the table (the actual table has much more variables and observations):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data dim_date;
  do date='01jan2025'd to '31dec2025'd;
        day_of_week_number=weekday(date);
        week_of_year_number=week(date);
       /**** Here I need a statement to calculate 
              acc_week_of_year_number *******/
        output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Does anyone have any idea on how to calculate that variable? Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 17:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959083#M374258</guid>
      <dc:creator>mvalsamis</dc:creator>
      <dc:date>2025-02-12T17:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of week in accounting year based on number of week in calendar year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959084#M374259</link>
      <description>&lt;P&gt;I don't see where you defined what an accounting year is.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 17:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959084#M374259</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-12T17:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of week in accounting year based on number of week in calendar year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959094#M374261</link>
      <description>&lt;P&gt;Sorry for the omission, and I just remembered it. In this case, the accounting year runs from 1st July to 30th June.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 19:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959094#M374261</guid>
      <dc:creator>mvalsamis</dc:creator>
      <dc:date>2025-02-12T19:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of week in accounting year based on number of week in calendar year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959096#M374262</link>
      <description>&lt;P&gt;You should also check out the three methods for calculatng week number as implemented in the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/n1ka2ulrvrjlasn0z7beco2yrgas.htm" target="_blank" rel="noopener"&gt;WEEK function&lt;/A&gt; to decide which is the appropriate one for you.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 19:42:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959096#M374262</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-02-12T19:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of week in accounting year based on number of week in calendar year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959102#M374263</link>
      <description>&lt;P&gt;Why not just use INTCK() function?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dim_date;
  do date='01jan2025'd to '07JAN2025'd
         ,'25jun2025'd to '04JUL2025'd
         ,'25dec2025'd to '31dec2025'd;
    year = year(date);
    fyear = year - (month(date)&amp;lt;7) ;
    day_of_week_number=weekday(date);
    week_of_year_number=week(date);
    acc_week_of_year_number=1+intck('week',mdy(7,1,fyear)-1,date);
    output;
  end;
  format date date9.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1739393839690.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104578i4A732003A6DAB95D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1739393839690.png" alt="Tom_0-1739393839690.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 20:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959102#M374263</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-02-12T20:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate number of week in accounting year based on number of week in calendar year</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959131#M374269</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/466760"&gt;@mvalsamis&lt;/a&gt;&amp;nbsp;Under the assumption that the first day of the first week always starts on July 1st, irrespective of the day of the week, the following should work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dim_date;
  format date date9.;
/*   do date='01jan2025'd to '31dec2025'd; */
  do date='27jun2025'd to '08jul2025'd;
    day_of_week_number=weekday(date);
    week_of_year_number=week(date);
    /* financial week with count starting 01July&amp;lt;year&amp;gt; irrespective of day of week */
    fin_week=int((date-intnx('year.7', date, 0, 'b'))/7)+1;
    output;
  end;
run;

proc print data=dim_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1739405483815.png" style="width: 577px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/104592iE90E7F1129F180C8/image-dimensions/577x369?v=v2" width="577" height="369" role="button" title="Patrick_0-1739405483815.png" alt="Patrick_0-1739405483815.png" /&gt;&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2025 00:12:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Calculate-number-of-week-in-accounting-year-based-on-number-of/m-p/959131#M374269</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2025-02-13T00:12:59Z</dc:date>
    </item>
  </channel>
</rss>

