<?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 macro loop error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26547#M4746</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you want the macro variables to be called?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 09 Oct 2011 16:28:36 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-10-09T16:28:36Z</dc:date>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26540#M4739</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have this below code working fine for positive parameters but throws an error for negative values. &lt;/P&gt;&lt;P&gt;could anyone help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro doit(m,n);&lt;/P&gt;&lt;P&gt;%do i=&amp;amp;m %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;%global st&amp;amp;i ;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; st=intnx('month',today(),&amp;amp;i,'b');&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symput("st&amp;amp;i",put(st,date9.));&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%doit(-2,-1)&lt;/P&gt;&lt;P&gt;%put &amp;amp;st-1 &amp;amp;st-2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 13:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26540#M4739</guid>
      <dc:creator>Kethy</dc:creator>
      <dc:date>2011-10-09T13:28:36Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26541#M4740</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It helps to post the error messages:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR: Invalid symbolic variable name -.&lt;/P&gt;&lt;P&gt;ERROR: Invalid symbolic variable name 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You cannot define a macro variable named ST-1 or ST-2.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 14:03:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26541#M4740</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-09T14:03:44Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26542#M4741</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how can i define then for negative values? any suggestion!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 15:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26542#M4741</guid>
      <dc:creator>Kethy</dc:creator>
      <dc:date>2011-10-09T15:19:49Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26543#M4742</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do you want to use it?&amp;nbsp; You count always just assign a counter.&amp;nbsp; The values can be negative but, like Tom said, the negatives can't be included in the macro variable name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 15:25:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26543#M4742</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-09T15:25:45Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26544#M4743</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i want to save the past month start date values into macro variables.how can this be done in above case?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 15:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26544#M4743</guid>
      <dc:creator>Kethy</dc:creator>
      <dc:date>2011-10-09T15:38:32Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26545#M4744</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if I fully understand, but do you want something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro doit(m,n);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i=&amp;amp;m %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %global last&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; st=intnx('month',today(),%eval(0-&amp;amp;i),'b');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("last"||strip(&amp;amp;i),put(st,date9.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%doit(1,2)&lt;/P&gt;&lt;P&gt;%put &amp;amp;last1 &amp;amp;last2;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 15:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26545#M4744</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-09T15:49:28Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26546#M4745</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right now im creating the macro variable "st" based on the i values as st&amp;amp;i, &lt;/P&gt;&lt;P&gt;when %doit(1,2) is called st1 and st2 will be the macro variables being created(no issues here)&lt;/P&gt;&lt;P&gt;when %doit(-2,-1) is called as pointed out by you and Tom negatives cannot be included in macro variables,&amp;nbsp; so in that case is there any better way where i can create a macro variable(instead of st&amp;amp;i) which would work fine in both the cases [ %doit(1,2) and %doit(-2,-1)]&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 16:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26546#M4745</guid>
      <dc:creator>Kethy</dc:creator>
      <dc:date>2011-10-09T16:22:44Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26547#M4746</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you want the macro variables to be called?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 16:28:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26547#M4746</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-09T16:28:36Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26548#M4747</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I mean when the macro %doit() is called irrespective of the positive or negative values being passed as parameters, it should create a macro variable which will hold the start of the month date corresponding to its values passed .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 16:43:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26548#M4747</guid>
      <dc:creator>Kethy</dc:creator>
      <dc:date>2011-10-09T16:43:14Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26549#M4748</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would something like the following suffice?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro doit(m,n);&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i=&amp;amp;m %to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; st=intnx('month',today(),&amp;amp;i,'b');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %if &amp;amp;i lt 0 %then %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %global before%eval(0-&amp;amp;i);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("before"||strip(%eval(0-&amp;amp;i)),put(st,date9.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %else %do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %global after&amp;amp;i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput("after"||strip(&amp;amp;i),put(st,date9.));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%doit(-2,-1)&lt;/P&gt;&lt;P&gt;%put &amp;amp;before1 &amp;amp;before2;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%doit(1,2)&lt;/P&gt;&lt;P&gt;%put &amp;amp;after1 &amp;amp;after2;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Oct 2011 17:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26549#M4748</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-09T17:53:25Z</dc:date>
    </item>
    <item>
      <title>macro loop error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26550#M4749</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great! Thanks art.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Oct 2011 00:10:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-loop-error/m-p/26550#M4749</guid>
      <dc:creator>Kethy</dc:creator>
      <dc:date>2011-10-10T00:10:25Z</dc:date>
    </item>
  </channel>
</rss>

