<?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: debug macro call execute, no error, no results in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267579#M52899</link>
    <description>&lt;P&gt;&lt;EM&gt;Hi,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Try below statement,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;call execute('%macro_missing (var='||strip(variable_name)||',def_val='||strip(De&lt;WBR /&gt;fault_value)||');');&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Guess you missed comma between parameters!&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Regards,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Manohar&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2016 12:41:40 GMT</pubDate>
    <dc:creator>Manu_SAS</dc:creator>
    <dc:date>2016-05-02T12:41:40Z</dc:date>
    <item>
      <title>debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267565#M52895</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I already tested the following script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;/* check 03: count missing */&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; create table base_missing as select VPS_AUFENTHALTSLAND,&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;case when VPS_AUFENTHALTSLAND in ('',' ','-','.') then 1 else 0 end as missing, &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;case when VPS_AUFENTHALTSLAND ='NB' then 1 else 0 end as default_value &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;from in.test ;run;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; create table base_missing as select sum(missing) as num_missing, &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;sum(default_value) as num_def_value from base_missing ;run;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; update DC.input_analysis_res &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;set number_missing_calc = (select num_missing FROM base_missing) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WHERE Variable_Name_Original='VPS_AUFENTHALTSLAND' ;run;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; update DC.input_analysis_res &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;set number_def_value = (select num_def_value FROM base_missing) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WHERE Variable_Name_Original='VPS_AUFENTHALTSLAND' ;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it works correctly. Now I would like to call it in a macro:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;step1:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%macro macro_missing (var=,def_val=);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; create table base_missing as select "&amp;amp;VAR",&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;case when "&amp;amp;VAR" in ('',' ','-','.') then 1 else 0 end as missing, &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;case when "&amp;amp;VAR" ="&amp;amp;def_val" then 1 else 0 end as default_value from in.test &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;;run;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; create table base_missing as select sum(missing) as num_missing,sum(default_value) as num_def_value &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;from base_missing ;run;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; update DC.input_analysis_res set number_missing_calc = (select num_missing FROM base_missing) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WHERE Variable_Name_Original="&amp;amp;VAR" ;run;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;proc sql; update DC.input_analysis_res set number_def_value = (select num_def_value FROM base_missing) &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WHERE Variable_Name_Original="&amp;amp;VAR" ;run;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%mend macro_missing;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;step 2:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data _null_;&lt;BR /&gt;set DC.input_analysis_res;&lt;BR /&gt;if Variable='VPS_AUFENTHALTSLAND';&lt;BR /&gt;call execute('%macro_missing (var='||strip(variable_name)||'def_val='||strip(Default_value)||');');&lt;BR /&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get neither an error message nor the expected results. Do someone have a suggestion? I do not see any error.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 11:30:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267565#M52895</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-05-02T11:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267576#M52898</link>
      <description>&lt;P&gt;Test your macro call without call execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your mistake is in how you reference the &amp;amp;Var macro variable. If it it is intended as a variable name do not include it in quotation marks. If it is a variable value then include it in quotation marks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fix that and test without call execute.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 12:34:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267576#M52898</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-02T12:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267579#M52899</link>
      <description>&lt;P&gt;&lt;EM&gt;Hi,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Try below statement,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;call execute('%macro_missing (var='||strip(variable_name)||',def_val='||strip(De&lt;WBR /&gt;fault_value)||');');&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Guess you missed comma between parameters!&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Regards,&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Manohar&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 12:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267579#M52899</guid>
      <dc:creator>Manu_SAS</dc:creator>
      <dc:date>2016-05-02T12:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267588#M52900</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/78691"&gt;@Sir_Highbury&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(...)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get neither an error message nor the expected results. Do someone have a suggestion? I do not see any error.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Dear Sir,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A close examination of the SAS log is always helpful in situations like this. The absence of error messages is necessary, but by no means sufficient for a perfect run of a program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I ran your code -- after creating test data, because you didn't supply any, and replacing the inappropriate RUN statements of PROC SQL steps by QUIT statements -- I saw, for example, this line in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;1 +   create table base_missing as select "VPS_AUFENTHALTSLANDdef_val=NB", case when "VPS_AUFENTHALTSLANDdef_val=NB" in ('','&lt;/PRE&gt;
&lt;P&gt;It shows two issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You missed the comma separating the macro parameters in the macro call created by CALL EXECUTE:&lt;BR /&gt;
&lt;PRE&gt;call execute('%macro_missing (var='||strip(variable_name)||'&lt;STRONG&gt;,&lt;/STRONG&gt; def_val=
                                                            ==&lt;/PRE&gt;
&lt;/LI&gt;
&lt;LI&gt;You try to compare a variable &lt;EM&gt;name&lt;/EM&gt; (VPS_AUFENTHALTSLAND) with&amp;nbsp;variable &lt;EM&gt;values&lt;/EM&gt; (' ', '-' etc.). To avoid this, please remove the quotation marks around &amp;amp;VAR in the &lt;EM&gt;first three&lt;/EM&gt; occurrences of&lt;BR /&gt;
&lt;PRE&gt;"&amp;amp;VAR"&lt;/PRE&gt;
in the macro code (but not in the last two occurrences).&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These two corrections might resolve the issues, but only if you really have all of the three variables&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Variable&lt;/LI&gt;
&lt;LI&gt;variable_name&lt;/LI&gt;
&lt;LI&gt;Variable_Name_Original&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;in dataset DC.input_analysis_res.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 13:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/267588#M52900</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-02T13:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/272978#M54346</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am back on the topic and thanks to your help the situation is getting better but there are still some issues. Here the first one.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;ERROR: Expression using IN has components that are of different data types.&lt;BR /&gt;NOTE: The IN referred to may have been transformed from an OR to an IN at some point during&lt;BR /&gt;PROC SQL WHERE clause optimization.&lt;BR /&gt;ERROR: Expression using equals (=) has components that are of different data types.&lt;BR /&gt;ERROR: The following columns were not found in the contributing tables: No.&lt;BR /&gt;1 +&lt;BR /&gt;run;&lt;BR /&gt;NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.07 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically writing:&amp;nbsp;&lt;/P&gt;&lt;P&gt;case when &amp;amp;VAR. in ('',' ','-','.') then 1 else 0 end as missing,&lt;BR /&gt;case when &amp;amp;VAR. =&amp;amp;def_val. then 1 else 0 end as default_value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to check if the variable is missing or a default value is used, applying the same logic to charachter and numeric variables.&lt;/P&gt;&lt;P&gt;How can do it? The check I would like to perform involve both numbers and charachter.&lt;/P&gt;&lt;P&gt;Attached the whole log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The fact that then I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 +&lt;BR /&gt;proc sql;&lt;BR /&gt;1 +&lt;BR /&gt;create&lt;BR /&gt;2 + table base_missing as select sum(missing) as num_missing,sum(default_value) as&lt;BR /&gt;num_def_value from base_missing ;&lt;BR /&gt;ERROR: File WORK.BASE_MISSING.DATA does not exist.&lt;BR /&gt;2 +&lt;BR /&gt;run;&lt;BR /&gt;NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.&lt;BR /&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE SQL used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;seems to be a direct consecquence of the first issue.&lt;/P&gt;&lt;P&gt;Thanks a lot again for you help! SH&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 15:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/272978#M54346</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-05-25T15:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273014#M54353</link>
      <description>&lt;P&gt;There are at least two issues:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Numeric variables &amp;amp;VAR cannot be compared directly to a list of character values.&lt;/LI&gt;
&lt;LI&gt;A comparison of a character variable &amp;amp;VAR to a value &amp;amp;def_val requires quotes around or in &amp;amp;def_val.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Possible solution:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;A quick (and a bit dirty) way of "applying the same logic to character and numeric variables" (as you desire) is to apply the CAT or (even better) CATS function to &amp;amp;VAR in order to convert its value to character:&lt;BR /&gt;case when &lt;STRONG&gt;cats(&lt;/STRONG&gt;&amp;amp;VAR&lt;STRONG&gt;)&lt;/STRONG&gt; in ...&lt;/LI&gt;
&lt;LI&gt;Since the values of macro variable DEF_VAL do not seem to be quoted, you can put &amp;amp;def_val into double quotes (as you did already in your initial post) and apply the CATS function to avoid potential issues with leading blanks:&lt;BR /&gt;case when &lt;STRONG&gt;cats(&lt;/STRONG&gt;&amp;amp;VAR&lt;STRONG&gt;)&lt;/STRONG&gt;=&lt;STRONG&gt;cats("&lt;/STRONG&gt;&amp;amp;def_val&lt;STRONG&gt;")&lt;/STRONG&gt;&amp;nbsp;then ...&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;And, again, PROC SQL steps should end with a QUIT statement, not a RUN statement.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 13:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273014#M54353</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-25T13:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273042#M54368</link>
      <description>&lt;P&gt;Rheinard that's&amp;nbsp;brilliant, thanks a lot for your your high effectiveness, flexibility and promptness.&lt;/P&gt;&lt;P&gt;Just one more point: basically I do ignore the difference between quit and run because it did not produce any mistake. Why should I care about it?&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 14:59:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273042#M54368</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-05-25T14:59:56Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273047#M54370</link>
      <description>&lt;P&gt;When you submit a single PROC SQL step without a QUIT statement, it will be executed, but the title bar of the Enhanced Editor will show the notification "PROC SQL running" to indicate that the step is not complete. Probably you didn't notice this in your program because subsequent DATA or PROC steps finish such&amp;nbsp;PROC SQL steps automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RUN statements in PROC SQL steps cause unnecessary messages&lt;/P&gt;
&lt;PRE&gt;NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.&lt;/PRE&gt;
&lt;P&gt;as you can see in your log. It's good practice in general to avoid unnecessary log messages, especially those with a negative statement (like "... has no effect").&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2016 15:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273047#M54370</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-05-25T15:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: debug macro call execute, no error, no results</title>
      <link>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273064#M54380</link>
      <description />
      <pubDate>Wed, 25 May 2016 16:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/debug-macro-call-execute-no-error-no-results/m-p/273064#M54380</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-05-25T16:18:16Z</dc:date>
    </item>
  </channel>
</rss>

