<?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/24566#M4174</link>
    <description>If  &amp;amp;NJcomplist resolves to having any special characters, you may need to call it as st= %str(&amp;amp;NJcomplist)&lt;BR /&gt;
&lt;BR /&gt;
Habitual use of a trailing "." with macro variables when you are not concatenating can get you into trouble as well.</description>
    <pubDate>Tue, 08 Mar 2011 22:57:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2011-03-08T22:57:25Z</dc:date>
    <item>
      <title>Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24561#M4169</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I am getting an error while running this below code:&lt;BR /&gt;
&lt;BR /&gt;
%macro cnt_inv(tbl=, vr=, st=,ds=);&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
create table &amp;amp;tbl.&lt;BR /&gt;
select count(*) as &amp;amp;vr. from &amp;amp;ds.&lt;BR /&gt;
where compno in (&amp;amp;st.)&lt;BR /&gt;
order by clamno lineno;&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend cnt_inv;&lt;BR /&gt;
&lt;BR /&gt;
%cnt_inv(tbl=pr_inv_nj_a, vr=prior_wk_inv, st=&amp;amp;complist, ds=test1);&lt;BR /&gt;
&lt;BR /&gt;
Error message:&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
ERROR: All positional parameters must precede keyword parameters&lt;BR /&gt;
&lt;BR /&gt;
Thanks in Advance</description>
      <pubDate>Tue, 08 Mar 2011 15:04:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24561#M4169</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-08T15:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24562#M4170</link>
      <description>The second error is probably from &amp;amp;complist, which you don't show.  If it has a comma in it, then the %cnt_inv will interpret the parts after the comma as positional parameters.  The macro needs a lot more work to handle things like &amp;amp;complist; there are examples in the macro manual.&lt;BR /&gt;
&lt;BR /&gt;
To get at the first error, you need to add some of the macro debugging options (macrogen in particular would help).&lt;BR /&gt;
&lt;BR /&gt;
Your order by clause should be a GROUP BY clause to go with the aggregate function COUNT.&lt;BR /&gt;
&lt;BR /&gt;
Doc Muhlbaier&lt;BR /&gt;
Duke</description>
      <pubDate>Tue, 08 Mar 2011 15:16:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24562#M4170</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2011-03-08T15:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24563#M4171</link>
      <description>The first error probably occurs because you are missing the word "as" in the create table statement.</description>
      <pubDate>Tue, 08 Mar 2011 15:33:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24563#M4171</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2011-03-08T15:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24564#M4172</link>
      <description>@ Polingjw : I iincluded the keyword but still am getting an error.&lt;BR /&gt;
ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;BR /&gt;
&lt;BR /&gt;
@Duke : I have included the macro debug options as below:&lt;BR /&gt;
&lt;BR /&gt;
Options symbolgen mlogic mprint;&lt;BR /&gt;
%put &amp;amp;njcomplist;&lt;BR /&gt;
%macro cnt_inv (tbl=, vr=, st=, table=);&lt;BR /&gt;
PROC SQL;&lt;BR /&gt;
create table '&amp;amp;tbl.' as&lt;BR /&gt;
select count(*) as "&amp;amp;vr." from '&amp;amp;table.'&lt;BR /&gt;
where compno in ('&amp;amp;st.')&lt;BR /&gt;
quit;&lt;BR /&gt;
%mend cnt_inv;&lt;BR /&gt;
%cnt_inv(tbl=pr_inv_nj_a,    vr=prior_wk_inv, st=&amp;amp;NJcomplist,  table=CLA378.outf_old);&lt;BR /&gt;
&lt;BR /&gt;
Please let me know how to resolve this error?&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
Raveena</description>
      <pubDate>Tue, 08 Mar 2011 17:14:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24564#M4172</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2011-03-08T17:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24565#M4173</link>
      <description>Hello Raveenat,&lt;BR /&gt;
&lt;BR /&gt;
I see single quotes around all macro variables in SQL Your previous post do not contain them. Variant with quotes is not correct. Please display &amp;amp;njcomplist. it is a good idea to run this code outside of the macro by assigning values (using %let) to all macro variables used. &lt;BR /&gt;
&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Tue, 08 Mar 2011 21:15:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24565#M4173</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-03-08T21:15:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24566#M4174</link>
      <description>If  &amp;amp;NJcomplist resolves to having any special characters, you may need to call it as st= %str(&amp;amp;NJcomplist)&lt;BR /&gt;
&lt;BR /&gt;
Habitual use of a trailing "." with macro variables when you are not concatenating can get you into trouble as well.</description>
      <pubDate>Tue, 08 Mar 2011 22:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/24566#M4174</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-03-08T22:57:25Z</dc:date>
    </item>
  </channel>
</rss>

