<?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: How do I set macro variable to the last week number of 2020 to 53 and not 52 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711614#M219247</link>
    <description>Ended up with this solution, including leading zeros, Thanks again !&lt;BR /&gt;%LET WEEK=W%sysfunc(week(%sysfunc(intnx(WEEK,%SYSFUNC(today()),0)),v),z2.);&lt;BR /&gt;%put &amp;amp;=week;&lt;BR /&gt;WEEK=W01&lt;BR /&gt;</description>
    <pubDate>Fri, 15 Jan 2021 08:11:29 GMT</pubDate>
    <dc:creator>PerBundgaard</dc:creator>
    <dc:date>2021-01-15T08:11:29Z</dc:date>
    <item>
      <title>How do I set macro variable to the last week number of 2020 to 53 and not 52</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711465#M219182</link>
      <description>&lt;P&gt;We have a scheduled task running each Monday morning setting start and stop date to the dates of the previous week, week starting Mondays&lt;/P&gt;&lt;P&gt;For example when running on 4'th January 2021 it sets the start and stop date to 28Dec2020 and 03 Jan2021 as follows:&lt;/P&gt;&lt;P&gt;%LET STARTDATE = %sysfunc(intnx(DAY,(%sysfunc(intnx(WEEK,(%SYSFUNC(today(),)),-1,b),)),+1),date9.);&lt;BR /&gt;%PUT &amp;amp;STARTDATE;&lt;BR /&gt;%LET STOPDATE = %sysfunc(intnx(DAY,(%sysfunc(intnx(WEEK,(%SYSFUNC(today(),)),-1,e),)),+1),date9.);&lt;BR /&gt;%PUT &amp;amp;STOPDATE;&lt;/P&gt;&lt;P&gt;We set another macro variable to the corresponding week number&lt;/P&gt;&lt;P&gt;With this year 2020/2021 we don't seem to be able to get the week number right (=53)&amp;nbsp; using the intnx function ...&lt;/P&gt;&lt;P&gt;%LET WEEK = %sysfunc(intnx(WEEK,(%SYSFUNC(today(),)),0),weeku3.);&lt;/P&gt;&lt;P&gt;Please suggest solution which would set the week number for running on 04Jan2021 to '53' and on 11Jan2021 to '01'&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 14:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711465#M219182</guid>
      <dc:creator>PerBundgaard</dc:creator>
      <dc:date>2021-01-14T14:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set macro variable to the last week number of 2020 to 53 and not 52</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711469#M219184</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/17271"&gt;@PerBundgaard&lt;/a&gt;&amp;nbsp; Are you looking to do this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET WEEK=%sysfunc(week(%sysfunc(intnx(WEEK,%SYSFUNC(today()),-1)),v));
%put &amp;amp;=week;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;14         %LET WEEK=%sysfunc(week(%sysfunc(intnx(WEEK,%SYSFUNC(today()),-1)),v));
15         %put &amp;amp;=week;
WEEK=53&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And likewise, for current week, setting the increment to 0-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;14         %LET WEEK=%sysfunc(week(%sysfunc(intnx(WEEK,%SYSFUNC(today()),0)),v));
15         %put &amp;amp;=week;
WEEK=1&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 15:10:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711469#M219184</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2021-01-14T15:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set macro variable to the last week number of 2020 to 53 and not 52</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711487#M219194</link>
      <description>Ahh, OK, the ‘v’ descriptor and the week function on top &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;BR /&gt;%LET WEEK = ;&lt;BR /&gt;%LET WEEK=W%sysfunc(week(%sysfunc(intnx(WEEK,'04Jan2021'D,0)),v));&lt;BR /&gt;%put &amp;amp;=week;&lt;BR /&gt;&lt;BR /&gt;Thanks a lot !&lt;BR /&gt;</description>
      <pubDate>Thu, 14 Jan 2021 16:08:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711487#M219194</guid>
      <dc:creator>PerBundgaard</dc:creator>
      <dc:date>2021-01-14T16:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set macro variable to the last week number of 2020 to 53 and not 52</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711614#M219247</link>
      <description>Ended up with this solution, including leading zeros, Thanks again !&lt;BR /&gt;%LET WEEK=W%sysfunc(week(%sysfunc(intnx(WEEK,%SYSFUNC(today()),0)),v),z2.);&lt;BR /&gt;%put &amp;amp;=week;&lt;BR /&gt;WEEK=W01&lt;BR /&gt;</description>
      <pubDate>Fri, 15 Jan 2021 08:11:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-set-macro-variable-to-the-last-week-number-of-2020-to/m-p/711614#M219247</guid>
      <dc:creator>PerBundgaard</dc:creator>
      <dc:date>2021-01-15T08:11:29Z</dc:date>
    </item>
  </channel>
</rss>

