<?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 debug call execute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267546#M52891</link>
    <description>&lt;P&gt;Dear Ballardw and Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry but I do not get your remark. If what you say is correct, why using the code (here below) outside the macro, the results are exactly as expected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql; create table values_found as select distinct VPS_AUFENTHALTSLAND from in.test group by 1; run;&lt;BR /&gt;proc sql; create table value_list as select distinct variable_value_list from DC.input_analysis_res where variable_name='VPS_AUFENTHALTSLAND' ;run;&lt;BR /&gt;proc sql; create table out_of_value_list as select distinct a.*, b.* from values_found a, value_list b ;run;&lt;BR /&gt;proc sql; create table out_of_value_list as select VPS_AUFENTHALTSLAND from out_of_value_list where Variable_value_list not contains VPS_AUFENTHALTSLAND ;run;&lt;BR /&gt;proc sql; create table out_of_value_list as select b.VPS_AUFENTHALTSLAND, count(*) as _n_ from out_of_value_list a, in.test b&lt;BR /&gt;where a.VPS_AUFENTHALTSLAND=b.VPS_AUFENTHALTSLAND group by 1 ;run;&lt;BR /&gt;proc sql; create table number_unexpected_values as select sum(_n_) as number_unexpected_values from out_of_value_list;run;&lt;BR /&gt;data unexpected_values_list (drop=VPS_AUFENTHALTSLAND rename=(tmp=VPS_AUFENTHALTSLAND));&lt;BR /&gt;length tmp $2000; set out_of_value_list end=last; retain tmp; tmp=catx(",",tmp,VPS_AUFENTHALTSLAND); if last then output ;run;&lt;BR /&gt;proc sql; update DC.input_analysis_res&lt;BR /&gt;set number_unexpected_value = (select number_unexpected_values FROM number_unexpected_values) WHERE Variable_Name_Original='VPS_AUFENTHALTSLAND' ;run;&lt;BR /&gt;proc sql; update DC.input_analysis_res&lt;BR /&gt;set Unexpected_values = (select VPS_AUFENTHALTSLAND FROM unexpected_values_list) WHERE Variable_Name_Original='VPS_AUFENTHALTSLAND' ;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the problem &lt;STRONG&gt;only &lt;/STRONG&gt;when I try to call the code within the macro. Thanks again for your explanation.&lt;/P&gt;</description>
    <pubDate>Mon, 02 May 2016 07:51:30 GMT</pubDate>
    <dc:creator>Sir_Highbury</dc:creator>
    <dc:date>2016-05-02T07:51:30Z</dc:date>
    <item>
      <title>Macro debug call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267262#M52802</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to debug a macro but I do not understand the error, attached the log. Does anyone of you understand it?&lt;/P&gt;
&lt;P&gt;I limited the macro to just one case (&lt;SPAN&gt;if Variable_value_list ne "" then */ --- replaced by ---&amp;gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;if variable_name='VPS_AUFENTHALTSLAND' then&lt;/SPAN&gt;) and the case standalone (running it outside the macro) wrok.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mlogic SYMBOLGEN;
%macro In_list (var=,vals=); /* check */
proc sql; 
create table values_found as
select distinct &amp;amp;VAR 
from in.test 
group by 1; 
run;


proc sql; 
create table &amp;amp;vals as 
select distinct variable_&amp;amp;vals 
from DC.input_analysis_res 
where variable_name='&amp;amp;VAR' ;
run;


proc sql; 
create table out_of_&amp;amp;vals as 
select distinct a.*, b.* 
from values_found a, &amp;amp;vals b ;
run;

proc sql; 
create table out_of_&amp;amp;vals as 
select &amp;amp;VAR from out_of_&amp;amp;vals 
where Variable_&amp;amp;vals not contains &amp;amp;VAR ;
run;


proc sql; 
create table out_of_&amp;amp;vals as 
select b.&amp;amp;VAR, count(*) as _n_ 
from out_of_&amp;amp;vals a, in.test b
where a.&amp;amp;VAR=b.&amp;amp;VAR group by 1 ;
run;


proc sql; 
create table number_unexpected_values as 
select sum(_n_) as number_unexpected_values 
from out_of_&amp;amp;vals;
run;

data unexpected_values_list (drop=&amp;amp;VAR rename=(tmp=&amp;amp;VAR));
length tmp $2000; 
set out_of_&amp;amp;vals end=last; 
retain tmp; 
tmp=catx(",",tmp,&amp;amp;VAR); 
if last then output ;
run;

proc sql; 
update DC.input_analysis_res
set number_unexpected_value = (select number_unexpected_values FROM number_unexpected_values) 
WHERE Variable_Name_Original='&amp;amp;VAR' ;
run;

proc sql; 
update DC.input_analysis_res
set Unexpected_values = (select &amp;amp;VAR FROM unexpected_values_list) 
WHERE Variable_Name_Original='&amp;amp;VAR' ;
run;

%mend In_List;
&amp;nbsp;
&amp;nbsp;
data _null_;
set DC.input_analysis_res;
/* check 01
if Variable_value_list ne "" then */
if variable_name='VPS_AUFENTHALTSLAND' then
call execute('%In_List (var='||strip(variable_name)||',vals='||strip(variable_value_list)||');');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:54:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267262#M52802</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-04-29T17:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro debug call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267263#M52803</link>
      <description>&lt;P&gt;Quick glance at your code, some usual suspects&amp;nbsp;caught my eyes, '&amp;amp;VAR'&amp;nbsp;, is this your real intention? macro instructions will not resolve inside&amp;nbsp; a pair of single quote. use double quote instead: "&amp;amp;VAR" to make it resolve. Not sure if this is your only issues.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 15:48:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267263#M52803</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2016-04-29T15:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macro debug call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267280#M52807</link>
      <description>&lt;P&gt;The line with the error on it show pretty clearly to me the logic error in your approach.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; create table DE FR JP as select distinct variable_DE FR JP from DC.input_analysis_res&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You seem to be passing in a space delimited list of values (DE FR JP) and are trying to treat it as both a dataset name and a variable name. &amp;nbsp;Neither of those can have spaces in them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:04:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267280#M52807</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-04-29T17:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro debug call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267288#M52812</link>
      <description>&lt;P&gt;These lines are all invalid when &amp;amp;VALS has more than one value&lt;/P&gt;
&lt;P&gt;proc sql; create table &amp;amp;vals as select distinct variable_&amp;amp;vals from DC.input_analysis_res where variable_name='&amp;amp;VAR' ;run;&lt;BR /&gt;proc sql; create table out_of_&amp;amp;&lt;STRONG&gt;vals&lt;/STRONG&gt; as select distinct a.*, b.* from values_found a&lt;STRONG&gt;, &amp;amp;vals&lt;/STRONG&gt; b ;run;&lt;BR /&gt;proc sql; create table out_of_&amp;amp;&lt;STRONG&gt;vals&lt;/STRONG&gt; as select &amp;amp;VAR from out_of_&amp;amp;vals where Variable&lt;STRONG&gt;_&amp;amp;vals&lt;/STRONG&gt; not contains &amp;amp;VAR ;run;&lt;BR /&gt;proc sql; create table out_of_&amp;amp;&lt;STRONG&gt;vals&lt;/STRONG&gt; as select b.&amp;amp;VAR, count(*) as _n_ from out_of_&amp;amp;&lt;STRONG&gt;vals&lt;/STRONG&gt; a, in.test b&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create table can only create one table so if&lt;/P&gt;
&lt;P&gt;create table &amp;amp;vals&lt;/P&gt;
&lt;P&gt;Generates create table AB CD EF&lt;/P&gt;
&lt;P&gt;or expects data from multiple sets such as in: from out_of_&amp;amp;&lt;STRONG&gt;vals&lt;/STRONG&gt; a&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is what is causing errors like this:&lt;/P&gt;
&lt;P&gt;NOTE: Line generated by the CALL EXECUTE routine.&lt;BR /&gt;1&amp;nbsp;&amp;nbsp; +&lt;BR /&gt; create &lt;STRONG&gt;table DE FR JP&lt;/STRONG&gt; as select &lt;STRONG&gt;distinct variable_DE FR JP&lt;/STRONG&gt; from DC.input_analysis_res&lt;BR /&gt;&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;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;&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;&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;&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;--&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One suspects a spelling error somewhere with this line;&lt;/P&gt;
&lt;P&gt;ERROR: File WORK.NUM_OURLIERS.DATA does not exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suspecting that NUM_OU&lt;STRONG&gt;T&lt;/STRONG&gt;LIERS may be intended.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also messages like this one:&lt;/P&gt;
&lt;P&gt;NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.&lt;/P&gt;
&lt;P&gt;May indicate that a LAST Proc sql is still running if the proc hasn't encountered another run boundary in the code. Remember that SQL wants a QUIT to end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Apr 2016 17:29:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267288#M52812</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-29T17:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: Macro debug call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267546#M52891</link>
      <description>&lt;P&gt;Dear Ballardw and Tom,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;sorry but I do not get your remark. If what you say is correct, why using the code (here below) outside the macro, the results are exactly as expected?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql; create table values_found as select distinct VPS_AUFENTHALTSLAND from in.test group by 1; run;&lt;BR /&gt;proc sql; create table value_list as select distinct variable_value_list from DC.input_analysis_res where variable_name='VPS_AUFENTHALTSLAND' ;run;&lt;BR /&gt;proc sql; create table out_of_value_list as select distinct a.*, b.* from values_found a, value_list b ;run;&lt;BR /&gt;proc sql; create table out_of_value_list as select VPS_AUFENTHALTSLAND from out_of_value_list where Variable_value_list not contains VPS_AUFENTHALTSLAND ;run;&lt;BR /&gt;proc sql; create table out_of_value_list as select b.VPS_AUFENTHALTSLAND, count(*) as _n_ from out_of_value_list a, in.test b&lt;BR /&gt;where a.VPS_AUFENTHALTSLAND=b.VPS_AUFENTHALTSLAND group by 1 ;run;&lt;BR /&gt;proc sql; create table number_unexpected_values as select sum(_n_) as number_unexpected_values from out_of_value_list;run;&lt;BR /&gt;data unexpected_values_list (drop=VPS_AUFENTHALTSLAND rename=(tmp=VPS_AUFENTHALTSLAND));&lt;BR /&gt;length tmp $2000; set out_of_value_list end=last; retain tmp; tmp=catx(",",tmp,VPS_AUFENTHALTSLAND); if last then output ;run;&lt;BR /&gt;proc sql; update DC.input_analysis_res&lt;BR /&gt;set number_unexpected_value = (select number_unexpected_values FROM number_unexpected_values) WHERE Variable_Name_Original='VPS_AUFENTHALTSLAND' ;run;&lt;BR /&gt;proc sql; update DC.input_analysis_res&lt;BR /&gt;set Unexpected_values = (select VPS_AUFENTHALTSLAND FROM unexpected_values_list) WHERE Variable_Name_Original='VPS_AUFENTHALTSLAND' ;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the problem &lt;STRONG&gt;only &lt;/STRONG&gt;when I try to call the code within the macro. Thanks again for your explanation.&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 07:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267546#M52891</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-05-02T07:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro debug call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267548#M52892</link>
      <description>&lt;P&gt;Thanks Haikuo,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there are still some errors in the log but, after correcting the code as you suggested, I get the results I expect.&lt;/P&gt;&lt;P&gt;Thanks a lot man!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BRs, Highbury&lt;/P&gt;</description>
      <pubDate>Mon, 02 May 2016 07:59:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-debug-call-execute/m-p/267548#M52892</guid>
      <dc:creator>Sir_Highbury</dc:creator>
      <dc:date>2016-05-02T07:59:43Z</dc:date>
    </item>
  </channel>
</rss>

