<?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 Macro variable inside call execute in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455081#M115081</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the end of a program I want to save a table from the WORK library to another library.The table name can also change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I created the macro SAVING:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro SAVING(
	library, 
	input_table,
	output_table);

PROC COPY 
inlib=WORK outlib= &amp;amp;library.;
SELECT &amp;amp;input_table.;
run;

%if %sysfunc(exist(&amp;amp;library..&amp;amp;output_table.)) %then %do;
	PROC DELETE DATA= &amp;amp;library..&amp;amp;output_table.;
%end;

PROC DATASETS NOPRINT library=&amp;amp;library.;
    change &amp;amp;input_table.= &amp;amp;output_table.;
run;
quit;
%mend;&lt;/PRE&gt;&lt;P&gt;My table name is store in a macrovariable. named outname.&lt;/P&gt;&lt;P&gt;I want to call the macro with the macrovariable name.&lt;/P&gt;&lt;PRE&gt;data _null_;

call execute('%SAVING(
					library = OUT_LIB,
					input_table = FINAL_TABLE,
					output_table = &amp;amp;outname.)');
run;&lt;/PRE&gt;&lt;P&gt;But when I do this I have an issue in front of the "change" row of the macro&lt;/P&gt;&lt;PRE&gt;73: LINE and COLUMN cannot be determined.
ERROR 73-322: Expecting an =.&lt;/PRE&gt;&lt;P&gt;Do you know what is wrong?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
    <pubDate>Wed, 18 Apr 2018 09:36:09 GMT</pubDate>
    <dc:creator>fabdu92</dc:creator>
    <dc:date>2018-04-18T09:36:09Z</dc:date>
    <item>
      <title>Macro variable inside call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455081#M115081</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the end of a program I want to save a table from the WORK library to another library.The table name can also change.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I created the macro SAVING:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro SAVING(
	library, 
	input_table,
	output_table);

PROC COPY 
inlib=WORK outlib= &amp;amp;library.;
SELECT &amp;amp;input_table.;
run;

%if %sysfunc(exist(&amp;amp;library..&amp;amp;output_table.)) %then %do;
	PROC DELETE DATA= &amp;amp;library..&amp;amp;output_table.;
%end;

PROC DATASETS NOPRINT library=&amp;amp;library.;
    change &amp;amp;input_table.= &amp;amp;output_table.;
run;
quit;
%mend;&lt;/PRE&gt;&lt;P&gt;My table name is store in a macrovariable. named outname.&lt;/P&gt;&lt;P&gt;I want to call the macro with the macrovariable name.&lt;/P&gt;&lt;PRE&gt;data _null_;

call execute('%SAVING(
					library = OUT_LIB,
					input_table = FINAL_TABLE,
					output_table = &amp;amp;outname.)');
run;&lt;/PRE&gt;&lt;P&gt;But when I do this I have an issue in front of the "change" row of the macro&lt;/P&gt;&lt;PRE&gt;73: LINE and COLUMN cannot be determined.
ERROR 73-322: Expecting an =.&lt;/PRE&gt;&lt;P&gt;Do you know what is wrong?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 09:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455081#M115081</guid>
      <dc:creator>fabdu92</dc:creator>
      <dc:date>2018-04-18T09:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable inside call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455092#M115087</link>
      <description>&lt;P&gt;You need to put double quotes around the text to invoke macro variables:&lt;/P&gt;
&lt;PRE&gt;data _null_;
 call execute(cats('%saving(library=out_lib,input_table=final_table,output_table=',"&amp;amp;outname.".');'));
run;&lt;/PRE&gt;
&lt;P&gt;Although I fail to see the need for that code, simply:&lt;/P&gt;
&lt;PRE&gt;data outlib.&amp;amp;outname.;
  set inlib.&amp;amp;outname.;
run;&lt;/PRE&gt;
&lt;P&gt;Does exactly the same job, with none of that fuss.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 09:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455092#M115087</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-18T09:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable inside call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455096#M115091</link>
      <description>&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is not exactly the same code, as in your case I have also a copy of FINAL_TABLE in the output library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could do this way nevertheless:&lt;/P&gt;&lt;PRE&gt;%macro SAVING(
	library, 
	input_table,
	output_table);

data &amp;amp;library..&amp;amp;output_table.;
set WORK.&amp;amp;input_table.;
run;

PROC DELETE DATA= &amp;amp;libray..&amp;amp;input_table.;
quit;
%mend;&lt;/PRE&gt;&lt;P&gt;But when I try this:&lt;/P&gt;&lt;PRE&gt;data _null_;
 call execute(cats('%saving(library=out_lib,input_table=final_table,output_table=',"&amp;amp;outname.".');'));
run;&lt;/PRE&gt;&lt;P&gt;I have this issue&amp;nbsp;in front of the macrovariable outname:&lt;/P&gt;&lt;PRE&gt;ERROR 388-185: Expecting an arithmetic operator.

ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Edit: This is how I create my macrovariable:&lt;/P&gt;&lt;PRE&gt;%let outname = p_201803;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Apr 2018 10:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455096#M115091</guid>
      <dc:creator>fabdu92</dc:creator>
      <dc:date>2018-04-18T10:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable inside call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455097#M115092</link>
      <description>&lt;P&gt;First of all, you can greatly reduce the complexity of the call execute with the macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute('%saving(temp,class,' !! "&amp;amp;outname" !! ');');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But then, you need to take care of timing when calling a macro that contains macro code with call execute:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname temp '/tmp';

data work.class;
set sashelp.class;
run;

%macro SAVING(
	library, 
	input_table,
	output_table);

PROC COPY 
inlib=WORK outlib= &amp;amp;library.;
SELECT &amp;amp;input_table.;
run;

%put executing macro statements;
%if %sysfunc(exist(&amp;amp;library..&amp;amp;output_table.)) %then %do;
	PROC DELETE DATA= &amp;amp;library..&amp;amp;output_table.;
%end;

PROC DATASETS NOPRINT library=&amp;amp;library.;
    change &amp;amp;input_table.= &amp;amp;output_table.;
run;
quit;
%mend;

%let outname=class1;

data _null_;
call execute('%saving(temp,class,' !! "&amp;amp;outname" !! ');');
run;

data _null_;
call execute('%nrstr(%saving(temp,class,' !! "&amp;amp;outname" !! '));');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Closely examine the logs from the two data _null_ / call execute steps. In the first, you will find that the %put happens BEFORE the first data step runs, while in the second, it happens where you intend your macro statements to execute. That is the function of the %nrstr() wrapped around the macro call.&lt;/P&gt;
&lt;P&gt;Why does this happen?&lt;/P&gt;
&lt;P&gt;When call execute pushes code onto the stack, and macro code is detected, the macro code is immediately handed over to the macro processor, while all data or procedure steps have to wait until the data step that makes the call execute has ended. %nrstr prevents immediate resolution of the macro statements contained inside, and so the macro keeps its timing.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 10:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455097#M115092</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-04-18T10:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable inside call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455098#M115093</link>
      <description>&lt;P&gt;There was a typo, dot rather than comma.&lt;/P&gt;
&lt;PRE&gt;data _null_;
 call execute(cats('%saving(library=out_lib,input_table=final_table,output_table=',"&amp;amp;outname.",');'));
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Apr 2018 10:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455098#M115093</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-18T10:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: Macro variable inside call execute</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455134#M115106</link>
      <description>&lt;P&gt;Check system macro variable &amp;amp;syslast.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.class;
run;


data x;
 set &amp;amp;syslast ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Apr 2018 12:52:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-variable-inside-call-execute/m-p/455134#M115106</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-04-18T12:52:44Z</dc:date>
    </item>
  </channel>
</rss>

