<?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: Macro to set variable to recurring dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218472#M40235</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's sort of what I assumed. If you run my code above it creates the macro variables starting from week0 instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To increment to 1 instead, increment the j variable. The WANT dataset helps to visualize what's happening but isn't required.&amp;nbsp; Y&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt; i = &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;54&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; dt=intnx(&lt;SPAN style="color: #942193;"&gt;'day'&lt;/SPAN&gt;,&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;'3apr2015'd&lt;/STRONG&gt;&lt;/SPAN&gt;,-i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;j=floor(i/&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt;)+&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;call&lt;/SPAN&gt; symput(catt(&lt;SPAN style="color: #942193;"&gt;'week'&lt;/SPAN&gt;, put(j, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt;&lt;/SPAN&gt; -l)), put(dt, &lt;SPAN style="color: #009193;"&gt;yymmddn8.&lt;/SPAN&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;put&lt;/SPAN&gt; dt=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;output&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; dt &lt;/SPAN&gt;yymmddn.&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week1.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week2.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week7.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;You could also use week&amp;nbsp; in your intnx function and loop your i for the number of weeks you're interested in. Also, I generally use Call symputX instead of Call symput as it trims spaces out automatically. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; date_start=01Apr2015;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;_null_&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt; i = &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; dt=intnx(&lt;SPAN style="color: #942193;"&gt;'week'&lt;/SPAN&gt;, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;"&amp;amp;date_start"d&lt;/STRONG&gt;&lt;/SPAN&gt;,-i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;call&lt;/SPAN&gt; symput&lt;STRONG&gt;X&lt;/STRONG&gt;(catt(&lt;SPAN style="color: #942193;"&gt;'week_new'&lt;/SPAN&gt;, put(i, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt;&lt;/SPAN&gt; -l)), put(dt, &lt;SPAN style="color: #009193;"&gt;yymmddn8.&lt;/SPAN&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;put&lt;/SPAN&gt; dt=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;output&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; dt &lt;/SPAN&gt;yymmddn.&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week_new1.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week_new2.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week_new12.;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Apr 2015 03:44:56 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-04-10T03:44:56Z</dc:date>
    <item>
      <title>Macro to set variable to recurring dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218469#M40232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Currently I do it manually, but I want to automate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is how I currently set the variables to every Friday in YYMMDDn8. format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let week1=20150403;&lt;/P&gt;&lt;P&gt;%let week2=20150327;&lt;/P&gt;&lt;P&gt;%let week3=20150320;&lt;/P&gt;&lt;P&gt;%let week4=20150313;&lt;/P&gt;&lt;P&gt;%let week5=20150306;&lt;/P&gt;&lt;P&gt;%let week6=20150227;&lt;/P&gt;&lt;P&gt;%let week7=20150213;&lt;/P&gt;&lt;P&gt;%let week8=20150206&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried and this is what I come up with, but how to assign it to a variable?&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;do i = 0 to 54 by 7;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dt=intnx('day','3apr2015'd,-i);&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symput('week',d);&lt;/P&gt;&lt;P&gt;&amp;nbsp; put week=;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 02:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218469#M40232</guid>
      <dc:creator>hellind</dc:creator>
      <dc:date>2015-04-10T02:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to set variable to recurring dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218470#M40233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;What do you mean by assign it to a variable? If you want a table don't use a data _null_ step. &lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Your week macro variable will only have the last value since you use the same macro variable name in each iteration of the loop.&amp;nbsp; Perhaps add the i to the variable name?&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Also, week is a macro variable so it isn't available in the same data step. There are workarounds for this, but probably not what you're looking for.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;Perhaps something like the following:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;data want;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;do i = 0 to 54 by 7;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; dt=intnx('day','3apr2015'd,-i);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt; j=floor(i/7);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; call symput(catt('week', put(j, 2. -l)),d);&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&amp;nbsp; put week=;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt; output;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;end;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 03:13:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218470#M40233</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-04-10T03:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to set variable to recurring dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218471#M40234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your assistance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't want a table, but I want to achieve this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week1=20150403;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week2=20150327;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week3=20150320;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week4=20150313;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week5=20150306;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week6=20150227;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week7=20150213;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;%let week8=20150206&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;and so on.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 03:32:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218471#M40234</guid>
      <dc:creator>hellind</dc:creator>
      <dc:date>2015-04-10T03:32:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro to set variable to recurring dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218472#M40235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's sort of what I assumed. If you run my code above it creates the macro variables starting from week0 instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To increment to 1 instead, increment the j variable. The WANT dataset helps to visualize what's happening but isn't required.&amp;nbsp; Y&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt; want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt; i = &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;0&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;54&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;by&lt;/SPAN&gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; dt=intnx(&lt;SPAN style="color: #942193;"&gt;'day'&lt;/SPAN&gt;,&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;'3apr2015'd&lt;/STRONG&gt;&lt;/SPAN&gt;,-i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;j=floor(i/&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;7&lt;/STRONG&gt;&lt;/SPAN&gt;)+&lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;call&lt;/SPAN&gt; symput(catt(&lt;SPAN style="color: #942193;"&gt;'week'&lt;/SPAN&gt;, put(j, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt;&lt;/SPAN&gt; -l)), put(dt, &lt;SPAN style="color: #009193;"&gt;yymmddn8.&lt;/SPAN&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;put&lt;/SPAN&gt; dt=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;output&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; dt &lt;/SPAN&gt;yymmddn.&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="color: #000000; font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week1.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week2.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week7.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt; font-family: arial, helvetica, sans-serif;"&gt;You could also use week&amp;nbsp; in your intnx function and loop your i for the number of weeks you're interested in. Also, I generally use Call symputX instead of Call symput as it trims spaces out automatically. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%let&lt;/SPAN&gt; date_start=01Apr2015;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #011993;"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;_null_&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;do&lt;/SPAN&gt; i = &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;to&lt;/SPAN&gt; &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;12&lt;/STRONG&gt;&lt;/SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; dt=intnx(&lt;SPAN style="color: #942193;"&gt;'week'&lt;/SPAN&gt;, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;"&amp;amp;date_start"d&lt;/STRONG&gt;&lt;/SPAN&gt;,-i);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;call&lt;/SPAN&gt; symput&lt;STRONG&gt;X&lt;/STRONG&gt;(catt(&lt;SPAN style="color: #942193;"&gt;'week_new'&lt;/SPAN&gt;, put(i, &lt;SPAN style="color: #009193;"&gt;&lt;STRONG&gt;2.&lt;/STRONG&gt;&lt;/SPAN&gt; -l)), put(dt, &lt;SPAN style="color: #009193;"&gt;yymmddn8.&lt;/SPAN&gt;));&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp; &lt;SPAN style="color: #0433ff;"&gt;put&lt;/SPAN&gt; dt=;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;output&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;end&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #009193;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000;"&gt; dt &lt;/SPAN&gt;yymmddn.&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #011993;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week_new1.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week_new2.;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;SPAN style="color: #0433ff;"&gt;%put&lt;/SPAN&gt; &amp;amp;week_new12.;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2015 03:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-to-set-variable-to-recurring-dates/m-p/218472#M40235</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-04-10T03:44:56Z</dc:date>
    </item>
  </channel>
</rss>

