<?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: How to tell SAS to run a macro that is contained in a Column of table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922036#M363104</link>
    <description>&lt;P&gt;You put CODE into an XSLX file?&amp;nbsp; Why?&lt;/P&gt;
&lt;P&gt;I jumped through the hoops needed to look at your attached file and it appears to CALLS to a macro in each cell.&amp;nbsp; So not a macro definition at all, just just normal SAS code that happens consist of macro calls.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The cleanest way is to write the code to a file and run the file.&lt;/P&gt;
&lt;P&gt;So assuming the dataset you get from the spreadsheet is named CALLS and the column with the SAS code is named CALL then use code like this to write that to a file and then use %INCLUDE to run it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
   set calls;
   file code;
   put call;
run;
%include code / source2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Mar 2024 19:20:04 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-03-27T19:20:04Z</dc:date>
    <item>
      <title>How to tell SAS to run a macro that is contained in a Column of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922009#M363098</link>
      <description>&lt;P&gt;&lt;FONT color="#000080"&gt;Hi,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080"&gt;I have created a macro in a column A called " final_macro" in the table attached (Macro_query).&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080"&gt; I would like to tell SAS to run it from the column A automatically?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080"&gt;Is it possible?&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080"&gt;Thank you&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 17:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922009#M363098</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2024-03-27T17:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell SAS to run a macro that is contained in a Column of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922034#M363103</link>
      <description>&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If by "column of table" you mean "a variable in a SAS data set" the answer is without looking in that spread is probably.&lt;/P&gt;
&lt;P&gt;A data step can use text in data set, or constructed text, with the CALL Execute statement to submit the text for execution.&lt;/P&gt;
&lt;P&gt;However, you are going to have to clarify what you mean by "automatically". Automatically when what happens?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 19:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922034#M363103</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-27T19:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell SAS to run a macro that is contained in a Column of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922036#M363104</link>
      <description>&lt;P&gt;You put CODE into an XSLX file?&amp;nbsp; Why?&lt;/P&gt;
&lt;P&gt;I jumped through the hoops needed to look at your attached file and it appears to CALLS to a macro in each cell.&amp;nbsp; So not a macro definition at all, just just normal SAS code that happens consist of macro calls.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The cleanest way is to write the code to a file and run the file.&lt;/P&gt;
&lt;P&gt;So assuming the dataset you get from the spreadsheet is named CALLS and the column with the SAS code is named CALL then use code like this to write that to a file and then use %INCLUDE to run it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
   set calls;
   file code;
   put call;
run;
%include code / source2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 19:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922036#M363104</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-27T19:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell SAS to run a macro that is contained in a Column of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922064#M363105</link>
      <description>&lt;P&gt;I personally would use the approach&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;proposes because it creates the "cleanest" log. An alternative would be call execute() or the dosubl() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test();
  %global i;
  %let i=%eval(&amp;amp;i+1);
  data _null_;
    var=&amp;amp;i;
    put var=;
  run;
%mend;

data macro_calls;
  infile datalines truncover;
  input code $100.;
  datalines4;
%test();
%test();
%test();
%test();
;;;;

data _null_;
  set macro_calls;
  call execute(code);
/*  rc=dosubl(code);*/
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 02:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922064#M363105</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-28T02:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to tell SAS to run a macro that is contained in a Column of table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922079#M363111</link>
      <description>&lt;P&gt;&lt;FONT color="#0000FF"&gt;Thank you Tom, for this.....That gives me what I need exactly, it works&amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;Best wishes&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 08:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-tell-SAS-to-run-a-macro-that-is-contained-in-a-Column-of/m-p/922079#M363111</guid>
      <dc:creator>Question</dc:creator>
      <dc:date>2024-03-28T08:41:35Z</dc:date>
    </item>
  </channel>
</rss>

