<?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: Storing and then executing a complete SAS steps/ progs as a macro variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914386#M360308</link>
    <description>&lt;P&gt;Just expand the macro variable between other steps in your program.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=sashelp.class;
run;

&amp;amp;step

proc print data=x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 03 Feb 2024 18:24:33 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-02-03T18:24:33Z</dc:date>
    <item>
      <title>Storing and then executing a complete SAS steps/ progs as a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914382#M360304</link>
      <description>&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;Wondering if we need to store a complete SAS steps/ procedure as a macro variable, how can we view those without any log issues and how can we execute those?&amp;nbsp; Example see below, I am capturing a simple data step in VARLIST, eventually want to capture that as a macro variable (&amp;amp;step) and then execute the resolved macro variable?&amp;nbsp; &amp;nbsp;Thank you.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
length varlist $1000;
varlist= " data x;length name $25; name='abc'; output; name='edfs'; output; run;";
run;
data _null_;
&amp;nbsp; &amp;nbsp; set test end=eof;
&amp;nbsp; &amp;nbsp; if eof then call symputx('step',varlist);
run;
%put %superq(&amp;amp;step);&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 03 Feb 2024 18:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914382#M360304</guid>
      <dc:creator>Ram_SAS</dc:creator>
      <dc:date>2024-02-03T18:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and then executing a complete SAS steps/ progs as a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914383#M360305</link>
      <description>&lt;P&gt;Remove the &amp;amp; from your code.&amp;nbsp; The %SUPERQ() function wants the NAME of a macro variable, not its value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%put %superq(step);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Feb 2024 18:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914383#M360305</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-03T18:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and then executing a complete SAS steps/ progs as a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914384#M360306</link>
      <description>&lt;P&gt;Thanks looks like I had&amp;nbsp; &amp;amp;step, when I was calling superq.&amp;nbsp; How can I execute those?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2024 18:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914384#M360306</guid>
      <dc:creator>Ram_SAS</dc:creator>
      <dc:date>2024-02-03T18:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and then executing a complete SAS steps/ progs as a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914385#M360307</link>
      <description>&lt;P&gt;I got it to work with Call execute as below, is there any other suggestions? Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data test;
length varlist $1000;
varlist= " data x;length name $25; name='abc'; output; name='edfs'; output; run;";
run;
data _null_;
    set test end=eof;
    if eof then call symputx('step',varlist);
	call execute('%NRSTR(' || "&amp;amp;step" || ')');
run;
%put %superq(step);&lt;/CODE&gt;&lt;/PRE&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>Sat, 03 Feb 2024 18:23:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914385#M360307</guid>
      <dc:creator>Ram_SAS</dc:creator>
      <dc:date>2024-02-03T18:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and then executing a complete SAS steps/ progs as a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914386#M360308</link>
      <description>&lt;P&gt;Just expand the macro variable between other steps in your program.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=sashelp.class;
run;

&amp;amp;step

proc print data=x;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Feb 2024 18:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914386#M360308</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-03T18:24:33Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and then executing a complete SAS steps/ progs as a macro variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914388#M360310</link>
      <description>&lt;P&gt;If the goal is just to run it immediately then there is no need to put it into a macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;call execute(trim(varlist));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or instead of macro variables you can put it into an actual FILE.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename code temp;
data _null_;
  set test;
  file code;
  put varlist;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then use %INCLUDE to run it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include code / source2;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What do you want to do when you have more than one block of code to store?&lt;/P&gt;
&lt;P&gt;For example perhaps you have a dataset that is something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  step+1;
  length varlist $1000;
  varlist= " data x;length name $25; name='abc'; output; name='edfs'; output; run;";
  output;
  step+1;
  varlist='proc print data=x; run;';
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now you can put it into multiple macro variables.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set test;
  call symputx(cats('step',step),varlist);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which you can then run independently.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;step1
proc sort data=x; 
  by name;
run;
&amp;amp;step2&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps just run them using call execute;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set test;
  call execute(catx(' ','* STEP',step,';'));
  call execute(trim(varlist));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Feb 2024 19:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Storing-and-then-executing-a-complete-SAS-steps-progs-as-a-macro/m-p/914388#M360310</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-03T19:18:07Z</dc:date>
    </item>
  </channel>
</rss>

