<?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 VA: WeekNumber from Monday to Sunday in SAS Visual Analytics</title>
    <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213958#M2295</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Giorgio&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Michelle mentioned it is probably best to prepare the data first. SAS has a&lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/67398/HTML/default/viewer.htm#n1ka2ulrvrjlasn0z7beco2yrgas.htm"&gt; WEEK Function&lt;/A&gt; that will allow you to compute the week according to different rules. The V option is the way we are used to in Europe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruno&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 May 2015 14:37:14 GMT</pubDate>
    <dc:creator>BrunoMueller</dc:creator>
    <dc:date>2015-05-13T14:37:14Z</dc:date>
    <item>
      <title>SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213956#M2293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to code a date variable by grouping the data that belong to the same week, using SAS Visual Analytics.&lt;/P&gt;&lt;P&gt;I found the "WeekNumber" function, that returns the number of the week in the current year. The problem is that I need the weeks to start on Mondays and to end on Sundays, whereas the SAS encoding is from Sunday to Saturday (the US encoding). Is there an easy way to prevent this problem to occur? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Giorgio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 09:40:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213956#M2293</guid>
      <dc:creator>data_ipr</dc:creator>
      <dc:date>2015-05-13T09:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213957#M2294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Giorgio,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not aware of a way to change the start of the week based on locale. This is similar to discussions in the group about having financial year calculations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For your week number requirement this can be achieved using SAS data step manipulation as part of the data preparation prior to loading the table into SAS Visual Analytics. There is a function, intck that can return the week number shifted by an interval so you can have it start on a Monday by using week.2 as the interval. Have a look at the user guide at &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/67398/HTML/default/viewer.htm#p1md4mx2crzfaqn14va8kt7qvfhr.htm" title="http://support.sas.com/documentation/cdl/en/lefunctionsref/67398/HTML/default/viewer.htm#p1md4mx2crzfaqn14va8kt7qvfhr.htm"&gt;SAS(R) 9.4 Functions - Intck&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, using something like INTCK("week.2", MDY(1,1,year(today())),date_column). You may need to change the start date depending on your requirements and also add 1 to the result if you don't want the first partial week to have a result of 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind Regards,&lt;/P&gt;&lt;P&gt;Michelle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 12:31:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213957#M2294</guid>
      <dc:creator>MichelleHomes</dc:creator>
      <dc:date>2015-05-13T12:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213958#M2295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Giorgio&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Michelle mentioned it is probably best to prepare the data first. SAS has a&lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/67398/HTML/default/viewer.htm#n1ka2ulrvrjlasn0z7beco2yrgas.htm"&gt; WEEK Function&lt;/A&gt; that will allow you to compute the week according to different rules. The V option is the way we are used to in Europe.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruno&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 14:37:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213958#M2295</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-05-13T14:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213959#M2296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahhhh good point to use the Week function if the start is the beginning of the calendar year. I find the INTCK and INTNX functions are my favourites as they are so versatile. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Michelle&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 14:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213959#M2296</guid>
      <dc:creator>MichelleHomes</dc:creator>
      <dc:date>2015-05-13T14:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213960#M2297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately, I do not have a SAS licence (but only a Visual Analytics one). Moreover, in order to implement an automatic flow, I need to run all my analysis based on SAS Visual Analytics, where this feature is absent.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 14:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213960#M2297</guid>
      <dc:creator>data_ipr</dc:creator>
      <dc:date>2015-05-13T14:57:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213961#M2298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When building your report you could create a conditional calculated numeric data item that returns WeekNumber for Monday to Saturday and&amp;nbsp; WeekNumber - 1 for Sunday.&amp;nbsp; For example, this calculated item text returns the WeekNumber of the variable Date for weeks starting on a Monday :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF ( DayOfWeek('Date'n) = 1 )&lt;/P&gt;&lt;P&gt;RETURN ( WeekNumber('Date'n) - 1 )&lt;/P&gt;&lt;P&gt;ELSE WeekNumber('Date'n)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only issue with this calculation is that the days before the first Sunday (or Monday) of the year have a WeekNumber of zero (0) - but that is the same whether your week starts on a Sunday or a Monday as the SAS Visual Analytics WeekNumber function returns 0 for the days between New Year's Day and the first Sunday of the year if New Year's Day is not a Sunday.&amp;nbsp; If you want New Year's Day to always be in the first week of the year then you also need to test what day New Year's Day falls on and which WeekNumber it is in too and then add 1 to the result of the WeekNumber function for all the other dates that year if New Year's Day would fall in WeekNumber zero (0) or was a Sunday. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 00:37:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213961#M2298</guid>
      <dc:creator>Cameron</dc:creator>
      <dc:date>2015-05-18T00:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213962#M2299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much, it was what I was looking for! &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 08:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213962#M2299</guid>
      <dc:creator>data_ipr</dc:creator>
      <dc:date>2015-05-18T08:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213963#M2300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Giorgio&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the following expression to calculate the week number as it is used in Europe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Format(TreatAs(_Number_, Trunc(( ( ( TreatAs(_Number_, 'startDate'n) - TreatAs(_Number_, DateFromMDY(1, 3, Year(TreatAs(_Date_, ( ( TreatAs(_Number_, 'startDate'n) - DayOfWeek(TreatAs(_Date_, ( TreatAs(_Number_, 'startDate'n) - 1 ))) ) + 4 ))))) ) + DayOfWeek(DateFromMDY(1, 3, Year(TreatAs(_Date_, ( ( TreatAs(_Number_, 'startDate'n) - DayOfWeek(TreatAs(_Date_, ( TreatAs(_Number_, 'startDate'n) - 1 ))) ) + 4 ))))) + 5 ) / 7 ))), 'Z2.0')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bruno&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 May 2015 16:29:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213963#M2300</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2015-05-18T16:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213964#M2301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;After some more research, I found that &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;if&lt;/STRONG&gt;&lt;/SPAN&gt; you have &lt;EM style="text-decoration: underline;"&gt;Data Administrator&lt;/EM&gt; rights, so that you can prepare data using the SAS Visual Data Builder, then you can add calculated column(s) that use SAS functions as part of the expression formula.&amp;nbsp; However, the WEEK function is not one of the formally listed "FUNCTIONS" keywords in the expression builder. So you would have to manually type the formula expression, using SAS syntax, rather than the Visual Analytics formula syntax that is used in the report designer.&amp;nbsp; This works for both SAS source tables as well as imported data because Visual Analytics uses a SAS macro (and the SQL Procedure) to prepare the data tables that ultimately get loaded into the SAS LASR Server. Unfortunately, not everyone can be a Data Administrator, so this option may not always be available when designing a report.&amp;nbsp; Also you might not want to go back and have to load (or reload) a different version of the table just to get something working on a single report, as this could use additional memory or impact on reports that have been built previously.&amp;nbsp; A better place to address the problem would be in the source data table(s) being loaded into Visual Analytics.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 May 2015 01:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/213964#M2301</guid>
      <dc:creator>Cameron</dc:creator>
      <dc:date>2015-05-19T01:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/332161#M6339</link>
      <description>&lt;P&gt;Hi Bruno&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have the problem med week-number and maked a copy of your expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I ha' still a problem. Can you see what my problem is??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Cosmic Kontakt start' is my 'startdate'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Format(TreatAs(_Number_, Trunc(( ( ( TreatAs(_Number_, ('Cosmic Kontakt start') - TreatAs(_Number_, DateFromMDY(1, 3, Year(TreatAs('Cosmic Kontakt start', ( ( TreatAs(_Number_, 'Cosmic Kontakt start') - DayOfWeek(TreatAs('Cosmic Kontakt start', ( TreatAs(_Number_, 'Cosmic Kontakt start') - 1 ))) ) + 4 ))))) ) + DayOfWeek(DateFromMDY(1, 3, Year(TreatAs('Cosmic Kontakt start', ( ( TreatAs(_Number_, 'Cosmic Kontakt start') - DayOfWeek(TreatAs('Cosmic Kontakt start', ( TreatAs(_Number_, 'Cosmic Kontakt start') - 1 ))) ) + 4 ))))) + 5 ) / 7 ))), 'Z2.0')&lt;/P&gt;</description>
      <pubDate>Mon, 13 Feb 2017 13:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/332161#M6339</guid>
      <dc:creator>Refsgaard1</dc:creator>
      <dc:date>2017-02-13T13:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/428819#M9172</link>
      <description>This solved for us a deffect, affecting 20 dashboards. THANKS</description>
      <pubDate>Thu, 18 Jan 2018 15:27:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/428819#M9172</guid>
      <dc:creator>BO1</dc:creator>
      <dc:date>2018-01-18T15:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/583039#M12956</link>
      <description>&lt;P&gt;Hi All&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;same issue here... I just use this :&amp;nbsp;&amp;nbsp;Week_Day = ifn(weekday(Date) = 1, 7, weekday(Date)-1);&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 02:07:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/583039#M12956</guid>
      <dc:creator>GenDemo</dc:creator>
      <dc:date>2019-08-22T02:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS VA: WeekNumber from Monday to Sunday</title>
      <link>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/584099#M12979</link>
      <description>&lt;P&gt;or:&lt;/P&gt;
&lt;P&gt;Weekday = input(put(Loan_Entry_Date, weekday2.),2.);&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2019 23:47:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Visual-Analytics/SAS-VA-WeekNumber-from-Monday-to-Sunday/m-p/584099#M12979</guid>
      <dc:creator>GenDemo</dc:creator>
      <dc:date>2019-08-26T23:47:04Z</dc:date>
    </item>
  </channel>
</rss>

