<?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 still compiled cannot implement again in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error-still-compiled-cannot-implement-again/m-p/669006#M200635</link>
    <description>&lt;P&gt;Please clarify what you mean by "cannot implement again".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A common first step in debugging anything involving macros is to set OPTIONS MPRINT; prior to running the code involving the macro(s). The log should contain more detailed output of the code generated by the macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An unfortunate fact of life when coding macros is that you can create code that will render a SAS session unstable with a variety of logic errors. Common ones involve unclosed or unbalanced quotes and parentheses.&lt;/P&gt;
&lt;P&gt;Without data we can't tell exactly what went wrong. If you are getting errors then post the log. If the SAS session appears not to be responding then you have one of the aforementioned code issues and you will likely have to shut down the SAS session and restart. SAVE code first if possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest that instead of blindly running a macro such as you have shown that you create a small data set and test each separate call in one call to Proc SQL. That may tell you which specific call(s) are causing problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect at least one of the issues is with this bit:&lt;/P&gt;
&lt;PRE&gt;, %case_when(sum(B_BGT_Amt
     ,t1.B_BGT_Amt)            as B_BGT_Amt format comma32.&lt;/PRE&gt;
&lt;P&gt;there are two ( but only one )&amp;nbsp; =&amp;gt; unbalanced parentheses.&lt;/P&gt;
&lt;P&gt;If you attempted to run this code more than once then you have likely stacked up multiple sets of unbalanced parentheses and can't recover.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jul 2020 22:36:29 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-07-13T22:36:29Z</dc:date>
    <item>
      <title>Macro Error still compiled cannot implement again</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error-still-compiled-cannot-implement-again/m-p/668996#M200629</link>
      <description>&lt;P&gt;&lt;BR /&gt;%macro case_when (case_1,case_2);&lt;BR /&gt;case&lt;BR /&gt;when t2.BGT_CNT &amp;gt; 1 then &amp;amp;case_1.&lt;BR /&gt;else &amp;amp;case_2.&lt;BR /&gt;end&lt;BR /&gt;%mend case_when;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql ;&lt;BR /&gt;create table Work.FORE_BGT_&amp;amp;period_file. as&lt;BR /&gt;select distinct&lt;BR /&gt;&amp;nbsp;&amp;nbsp;t1.PJT_NO&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN3&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN4&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN5&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.Task_Name1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, %case_when(sum(t1.B_Qty)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;, t1.B_Qty)&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;as B_Qty&amp;nbsp;&amp;nbsp;format comma32.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, %case_when("KRW"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,t1.B_Curr)&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;as B_Curr&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, %case_when(1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,t1.B_Rate)&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;as B_Rate&amp;nbsp;&amp;nbsp;format comma32.2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, %case_when(sum(B_BGT_Amt) / sum(t1.B_Qty)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,t1.B_Unit)&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;as B_Unit&amp;nbsp;&amp;nbsp;format comma32.1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, %case_when(sum(B_BGT_Amt&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,t1.B_BGT_Amt)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;as B_BGT_Amt&amp;nbsp;format comma32.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, %case_when(sum(sum(B_AOP_Amt)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;,t1.B_AOP_Amt)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;as B_AOP_Amt&amp;nbsp;format comma32.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;From Work.FORE_BGT_RAW_&amp;amp;period_file.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;as t1&lt;/P&gt;&lt;P&gt;Left Join Work.FORE_BGT_Curr_CNT_&amp;amp;period_file. &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;as t2&lt;BR /&gt;on t1.PJT_NO = t2.PJT_NO&lt;BR /&gt;and t1.GUBUN1 = t2.GUBUN1&lt;BR /&gt;and t1.GUBUN2 = t2.GUBUN2&lt;BR /&gt;and t1.GUBUN3 = t2.GUBUN3&lt;BR /&gt;and t1.GUBUN4 = t2.GUBUN4&lt;BR /&gt;and t1.GUBUN5 = t2.GUBUN5&lt;BR /&gt;and t1.Task_Name1 = t2.Task_Name1&lt;/P&gt;&lt;P&gt;group by&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; t1.PJT_NO&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN3&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN4&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN5&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.Task_Name1&lt;/P&gt;&lt;P&gt;order by&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; t1.PJT_NO&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.Task_Name1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN2&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN3&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN4&lt;BR /&gt;&amp;nbsp;&amp;nbsp;, t1.GUBUN5&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 22:12:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error-still-compiled-cannot-implement-again/m-p/668996#M200629</guid>
      <dc:creator>Hodoree</dc:creator>
      <dc:date>2020-07-13T22:12:21Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error still compiled cannot implement again</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error-still-compiled-cannot-implement-again/m-p/669006#M200635</link>
      <description>&lt;P&gt;Please clarify what you mean by "cannot implement again".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A common first step in debugging anything involving macros is to set OPTIONS MPRINT; prior to running the code involving the macro(s). The log should contain more detailed output of the code generated by the macros.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An unfortunate fact of life when coding macros is that you can create code that will render a SAS session unstable with a variety of logic errors. Common ones involve unclosed or unbalanced quotes and parentheses.&lt;/P&gt;
&lt;P&gt;Without data we can't tell exactly what went wrong. If you are getting errors then post the log. If the SAS session appears not to be responding then you have one of the aforementioned code issues and you will likely have to shut down the SAS session and restart. SAVE code first if possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest that instead of blindly running a macro such as you have shown that you create a small data set and test each separate call in one call to Proc SQL. That may tell you which specific call(s) are causing problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect at least one of the issues is with this bit:&lt;/P&gt;
&lt;PRE&gt;, %case_when(sum(B_BGT_Amt
     ,t1.B_BGT_Amt)            as B_BGT_Amt format comma32.&lt;/PRE&gt;
&lt;P&gt;there are two ( but only one )&amp;nbsp; =&amp;gt; unbalanced parentheses.&lt;/P&gt;
&lt;P&gt;If you attempted to run this code more than once then you have likely stacked up multiple sets of unbalanced parentheses and can't recover.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 22:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error-still-compiled-cannot-implement-again/m-p/669006#M200635</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-13T22:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error still compiled cannot implement again</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error-still-compiled-cannot-implement-again/m-p/669009#M200637</link>
      <description>&lt;P&gt;Thank you Sir !!&lt;/P&gt;&lt;P&gt;I solved this problem for your advise.&lt;/P&gt;&lt;P&gt;parenthesis&amp;nbsp;is incorrect&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 22:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error-still-compiled-cannot-implement-again/m-p/669009#M200637</guid>
      <dc:creator>Hodoree</dc:creator>
      <dc:date>2020-07-13T22:47:56Z</dc:date>
    </item>
  </channel>
</rss>

