<?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 Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232260#M42319</link>
    <description>&lt;P&gt;It may help to show the program that worke &lt;STRONG&gt;without&lt;/STRONG&gt; macros so we can tell what you are actually attempting to accomplish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see a number of other issues:&lt;/P&gt;
&lt;P&gt;You assign a value to a macro variable name Variable but don't use it.&lt;/P&gt;
&lt;P&gt;You create a reference to variables V1 V2 etc in the resulting code. Are you sure those variables exist in the input data set?&lt;/P&gt;</description>
    <pubDate>Thu, 29 Oct 2015 16:24:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-10-29T16:24:38Z</dc:date>
    <item>
      <title>Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232242#M42312</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to write some macro in sas. However, it is not working. Here is the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* %macro product(num, v1, v2, v3, v4, v5, v6, v7, v8);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %macro product(num, variable1-variable&amp;amp;n);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;%let produc = 0;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let variable = 'var';&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;%do j = 1 %to &amp;amp;num;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let k=j;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;produc = &amp;amp;produc + j * v&amp;amp;k;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;%end;&lt;BR /&gt;%mend product;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let n = 8;&lt;BR /&gt;%let prod = 162;&lt;/P&gt;&lt;P&gt;data zeo_corr.perm&amp;amp;n (keep= var1 - var&amp;amp;n produc)&lt;/P&gt;&lt;P&gt;length default = 3;&lt;BR /&gt;array a{&amp;amp;n} var1-var&amp;amp;n;&lt;BR /&gt;do&amp;nbsp;j = 1 to&amp;nbsp;10000;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i = 1 to &amp;amp;n;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; a[i]=j;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %product(&amp;amp;n, var1- var&amp;amp;n);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; *&amp;nbsp;%product(&amp;amp;n, var1, var2, var3, var4, var5, var6, var7, var8);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if produc = &amp;amp;prod then output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it is showing the following error&lt;/P&gt;&lt;P&gt;NOTE: Line generated by the macro variable "PRODUC".&lt;BR /&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 180&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: More positional parameters found than defined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where is the problem? Please suggest me the possible solution.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 15:51:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232242#M42312</guid>
      <dc:creator>kstatju</dc:creator>
      <dc:date>2015-10-29T15:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232255#M42317</link>
      <description>&lt;P&gt;This line will cause trouble:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;amp;produc = &amp;amp;produc + j * v&amp;amp;k;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since &amp;amp;produc is 0, you are generating a statement that begins with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 = 0 + ...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;0 to the left of an equal sign will not give you a valid SAS statement.&amp;nbsp; So you need to first determine what SAS statement belongs at that point in the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 16:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232255#M42317</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-10-29T16:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232260#M42319</link>
      <description>&lt;P&gt;It may help to show the program that worke &lt;STRONG&gt;without&lt;/STRONG&gt; macros so we can tell what you are actually attempting to accomplish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see a number of other issues:&lt;/P&gt;
&lt;P&gt;You assign a value to a macro variable name Variable but don't use it.&lt;/P&gt;
&lt;P&gt;You create a reference to variables V1 V2 etc in the resulting code. Are you sure those variables exist in the input data set?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 16:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232260#M42319</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-29T16:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232268#M42325</link>
      <description>&lt;P&gt;New code and its Error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let n = 8;&lt;BR /&gt;%let z = 40;&lt;BR /&gt;%let prod = 162;&lt;/P&gt;&lt;P&gt;%macro product(num, var1, var2, var3, var4, var5, var6, var7, var8);&lt;BR /&gt;&amp;nbsp;%let produc = 0;&lt;BR /&gt;&amp;nbsp;%let variable = var;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%do j = 1 %to num;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;%let k=j;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;sum = %SYSFUNC(sum(&amp;amp;produc + j * %SYSFUNC(cat(&amp;amp;&amp;amp;variable&amp;amp;k))));&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;amp;produc = sum;&lt;BR /&gt;&amp;nbsp;%end;&lt;BR /&gt;%mend product;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/** generate all permutations of n elements, in order **/&lt;/P&gt;&lt;P&gt;data zeo_corr.perm&amp;amp;n (keep= var1 - var&amp;amp;n);&lt;BR /&gt;length default = 3;&lt;BR /&gt;array a{&amp;amp;n} var1-var&amp;amp;n;&lt;BR /&gt;do i = 1 to fact(&amp;amp;n);&lt;BR /&gt;&amp;nbsp;&amp;nbsp; do i = 1 to &amp;amp;n;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; a[i]=i;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;num = &amp;amp;n;&lt;BR /&gt;&amp;nbsp;%product(num, var1, var2, var3, var4, var5, var6, var7, var8);&lt;BR /&gt;&amp;nbsp;if produc = &amp;amp;prod then output;&lt;/P&gt;&lt;P&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operand is required. The condition was: num&lt;BR /&gt;ERROR: The %TO value of the %DO J loop is invalid.&lt;BR /&gt;ERROR: The macro PRODUCT will stop executing.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 16:52:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232268#M42325</guid>
      <dc:creator>kstatju</dc:creator>
      <dc:date>2015-10-29T16:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232273#M42326</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/60148"&gt;@kstatju&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;New code and its Error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;%let variable = var;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;%do j = 1 %to num;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;%let k=j&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operand is required. The condition was: num&lt;BR /&gt;ERROR: The %TO value of the %DO J loop is invalid.&lt;BR /&gt;ERROR: The macro PRODUCT will stop executing.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;shouldn't it be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;%do j = 1 %to &amp;amp;num;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 17:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232273#M42326</guid>
      <dc:creator>slangan</dc:creator>
      <dc:date>2015-10-29T17:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232274#M42327</link>
      <description>&lt;P&gt;kstatju,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I agree with ballardw ... there are too many issues with the code to work out each one individually here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take the code, reduce it from 8 variables down to 4 variables, and get rid of all the macro language.&amp;nbsp; Come up with working code using just SAS language, and then we can worry about how to turn your code into a macro.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 17:21:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232274#M42327</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-10-29T17:21:28Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232275#M42328</link>
      <description>&lt;P&gt;Do NOT use statement style comments (*....; ) to attempt to comment out macro code. &amp;nbsp;The macro code inside of these statements will continue to be evaluated the same as they would inside of any other statement. Either use blocks comments&amp;nbsp;(/*....*/) or macro comments (%*....; ).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 17:29:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232275#M42328</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-29T17:29:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232278#M42329</link>
      <description>&lt;P&gt;I do not see what the macro logic is adding to this data step. &amp;nbsp;Why not just use a normal data step DO loop?&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 17:35:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232278#M42329</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-10-29T17:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232298#M42338</link>
      <description>&lt;P&gt;And learn to use the system options MPRINT and SYMBOLGEN to see what your code is generating. The errors will appear in the log closer to the actual cause instead of all at the end of the macro.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 18:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232298#M42338</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-29T18:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232467#M42370</link>
      <description>&lt;P&gt;Thank you all. Great help!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 16:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/232467#M42370</guid>
      <dc:creator>kstatju</dc:creator>
      <dc:date>2015-10-30T16:00:29Z</dc:date>
    </item>
  </channel>
</rss>

