<?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: Statement is not valid or it is used out of proper order with Proc SQL inside Macro in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148994#M11720</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And one more idea, as I examine the SQL code a bit more.&amp;nbsp; It looks like you're trying to "enrich" another data set with some SAS Business Rules Manager output.&amp;nbsp; Do you think that you might instead be able to refactor your INSERT/SELECT code into a JOIN where you combine the two data sources based on matching criteria?&amp;nbsp; If you're using SAS Enterprise Guide, you might be able to play with the Query Builder to join the two data sets into your desired output -- or at least an output that you could then append back on to the &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;RAS.RATE_ASSIGNMENT_BIZ target table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Dec 2014 21:15:27 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2014-12-12T21:15:27Z</dc:date>
    <item>
      <title>Statement is not valid or it is used out of proper order with Proc SQL inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148990#M11716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Below is the code I was using&lt;/P&gt;&lt;P&gt;%macro ins(ruleset_id);&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;insert into RAS.RATE_ASSIGNMENT_BIZ&lt;/P&gt;&lt;P&gt;(BRM_RULESET_ID,&lt;/P&gt;&lt;P&gt;BRM_RULESET_NAME,&lt;/P&gt;&lt;P&gt;RATE_ASSIGNMENT_NAME,&lt;/P&gt;&lt;P&gt;XREF_ANALYSIS_ID,&lt;/P&gt;&lt;P&gt;ANALYST_ID,&lt;/P&gt;&lt;P&gt;EXISTING_GLOBAL_MIN ,&lt;/P&gt;&lt;P&gt;EXISTING_GLOBAL_MEDIAN,&lt;/P&gt;&lt;P&gt;EXISTING_GLOBAL_MAX,&lt;/P&gt;&lt;P&gt;EXISTING_LOCAL_MIN,&lt;/P&gt;&lt;P&gt;EXISTING_LOCAL_MEDIAN,&lt;/P&gt;&lt;P&gt;EXISTING_LOCAL_MAX,&lt;/P&gt;&lt;P&gt;SALES_LEVEL_1_DESCRIPTION,&lt;/P&gt;&lt;P&gt;ELEMENT,&lt;/P&gt;&lt;P&gt;PRICE_LIST_NAME,&lt;/P&gt;&lt;P&gt;ACTION_STATUS,&lt;/P&gt;&lt;P&gt;ACTION_REASON,&lt;/P&gt;&lt;P&gt;ANALYST_ID,&lt;/P&gt;&lt;P&gt;ANALYST_NAME)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT BRM_RULESET_ID,BRM_RULESET_NAME,RATE_ASSIGNMENT_NAME,XREF_ANALYSIS_ID,ANALYST_ID,&lt;/P&gt;&lt;P&gt;EXISTING_GLOBAL_MIN ,&lt;/P&gt;&lt;P&gt;EXISTING_GLOBAL_MEDIAN,&lt;/P&gt;&lt;P&gt;EXISTING_GLOBAL_MAX,&lt;/P&gt;&lt;P&gt;EXISTING_LOCAL_MIN,&lt;/P&gt;&lt;P&gt;EXISTING_LOCAL_MEDIAN,&lt;/P&gt;&lt;P&gt;EXISTING_LOCAL_MAX,&lt;/P&gt;&lt;P&gt;SALES_LEVEL_1_DESCRIPTION,&lt;/P&gt;&lt;P&gt;ELEMENT,&lt;/P&gt;&lt;P&gt;PRICE_LIST_NAME,&lt;/P&gt;&lt;P&gt;ACTION_STATUS,&lt;/P&gt;&lt;P&gt;ACTION_REASON,&lt;/P&gt;&lt;P&gt;ANALYST_ID,&lt;/P&gt;&lt;P&gt;ANALYST_NAME&lt;/P&gt;&lt;P&gt;FROM progress.RAS_COMPLETED_RATES&lt;/P&gt;&lt;P&gt;WHERE BRM_RULESET_ID = &amp;amp;ruleset_id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%mend ins;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am getting the erorr "ERROR 180-322: Statement is not valid or it is used out of proper order." When I call this macro inside a datasetp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please help me with the issue here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 20:51:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148990#M11716</guid>
      <dc:creator>ykk</dc:creator>
      <dc:date>2014-12-12T20:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: Statement is not valid or it is used out of proper order with Proc SQL inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148991#M11717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cannot call a PROC SQL step within a DATA step, and since this macro expands to a full PROC SQL step, the resulting syntax is invalid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really need this step to execute for every iteration (observation) in a DATA step, you can use DOSUBL to invoke it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's a paper on the topic:&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings12/227-2012.pdf" title="http://support.sas.com/resources/papers/proceedings12/227-2012.pdf"&gt;http://support.sas.com/resources/papers/proceedings12/227-2012.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And some examples from my blog:&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://blogs.sas.com/content/sasdummy/2013/01/30/tracking-progress-with-dosubl/" title="http://blogs.sas.com/content/sasdummy/2013/01/30/tracking-progress-with-dosubl/"&gt; Tracking progress in your program with SAS Enterprise Guide: another trick&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 20:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148991#M11717</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2014-12-12T20:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Statement is not valid or it is used out of proper order with Proc SQL inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148992#M11718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please show the code where you call the macro?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If by "call this macro inside a datastep" you mean something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %ins(5)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; *more data step code here;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will have problems, because you would be trying to run a PROC SQL step inside a data step, which doesn't work.&amp;nbsp;&amp;nbsp; The proc SQL step will end the data step, and any data step code after the macro invocation will cause an error like you're getting.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are trying to generate a bunch of macro calls from data, look into call execute.&amp;nbsp; It allows you to generate the PROC SQL code, but the code is not actually executed until after the data step is completed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;--Q.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 20:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148992#M11718</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2014-12-12T20:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: Statement is not valid or it is used out of proper order with Proc SQL inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148993#M11719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How are you call this in a data set?&lt;/P&gt;&lt;P&gt;If you paste the above code with a value for &amp;amp;ruleset_id into the data step currently calling this macro will it run?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 21:03:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148993#M11719</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-12-12T21:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: Statement is not valid or it is used out of proper order with Proc SQL inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148994#M11720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And one more idea, as I examine the SQL code a bit more.&amp;nbsp; It looks like you're trying to "enrich" another data set with some SAS Business Rules Manager output.&amp;nbsp; Do you think that you might instead be able to refactor your INSERT/SELECT code into a JOIN where you combine the two data sources based on matching criteria?&amp;nbsp; If you're using SAS Enterprise Guide, you might be able to play with the Query Builder to join the two data sets into your desired output -- or at least an output that you could then append back on to the &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;RAS.RATE_ASSIGNMENT_BIZ target table.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 21:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148994#M11720</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2014-12-12T21:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Statement is not valid or it is used out of proper order with Proc SQL inside Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148995#M11721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Quentin Call Execute Worked for me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 21:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Statement-is-not-valid-or-it-is-used-out-of-proper-order-with/m-p/148995#M11721</guid>
      <dc:creator>ykk</dc:creator>
      <dc:date>2014-12-12T21:37:30Z</dc:date>
    </item>
  </channel>
</rss>

