<?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: Using IML executefile() to execute SAS code written to an external file in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855014#M5950</link>
    <description>&lt;P&gt;You're not "exceeding the bounds of PROC IML." You can construct multiple statements and send them into the SUBMIT block, but it is easier and simpler to use use the GROUP= option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, you accidentally selected your own response as the correct answer.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Jan 2023 11:17:18 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2023-01-23T11:17:18Z</dc:date>
    <item>
      <title>Using IML executefile() to execute SAS code written to an external file</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/854724#M5945</link>
      <description>&lt;P&gt;Is there a way that I can write SAS statistical graphics commands to an external file and then use the executefile() function to submit the code in the file for execution?&lt;/P&gt;
&lt;P&gt;I know that IML has statistical graphics capability, but I want to write commands to the external file based on the parameters to a module and I need program-driven flexibility to do so.&lt;/P&gt;
&lt;P&gt;For example, if there are two series, e.g., (x1, y1) and (x2,y2) then I want to tell SGPLOT to execute two SERIES statements. And if there are three series, I want to see three series on the plot that I generate.&lt;/P&gt;
&lt;P&gt;Thus, I want my module to write the following external file for the following example:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&amp;lt;ODS html statements here&amp;gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;proc sgplot data=sgplot_data ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;series x=x1 y=y1 ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;series x=x2 y=y2 ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;run ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;ODS html close ;&lt;/P&gt;
&lt;P&gt;and for the second example:&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;&amp;lt;ODS html statements here&amp;gt;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;proc sgplot data=sgplot_data ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;series x=x1 y=y1 ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;series x=x2 y=y2 ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-60px"&gt;series x=x3 y=y3 ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;run ;&lt;/P&gt;
&lt;P class="lia-indent-padding-left-30px"&gt;ODS html close ;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 02:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/854724#M5945</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2023-01-20T02:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using IML executefile() to execute SAS code written to an external file</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/854782#M5946</link>
      <description>&lt;P&gt;Executefile() will not do what you want as it is designed for including SAS/IML statements from a file.&amp;nbsp; There are probably two options to do what you want - take a look at the submit/endsubmit statements which you can use to run general SAS statements from within an IML program.&amp;nbsp; If this does not have the flexibility you need, then create a file from within IML that later is %included after IML has finished running.&amp;nbsp; For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename gcode "&amp;amp;mypath\graphics_code.sas";

proc iml;
  file gcode;
  nplot=3;
  put 'proc sgplot data=sgplot_data;';
  do i=1 to nplot;
    s = 'series x=x' + strip(char(i)) + ' y=y' + strip(char(i)) + ';';
	put s;
  end;
  put 'run;';
  closefile gcode;
quit ;

%include gcode;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jan 2023 09:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/854782#M5946</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2023-01-20T09:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using IML executefile() to execute SAS code written to an external file</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/854809#M5947</link>
      <description>&lt;P&gt;The cleanest solution is to write the data in long form, not wide form. Then the following SUBMIT/ENDSUBMIT call always use gives the correct number of lines with no special coding:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;submit;
proc sgplot data=Have;
series x=x y=y / group=ID;
run;
endsubmit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the X variables are all the same, you can use the WIDETOLONG subroutine in PROC IML to create the long data. Otherwise, you can use something like the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
do x1 = 0 to 6 by 0.5;
   x2 = -1 + 1.1*x1;
   x3 = 1 + 0.9*x1;
   y1 = sin(x1);
   y2 = cos(x2);
   y3 = exp(-x3);
   output;
end;
run;

proc iml;
use Have;
read all var {x1 x2 x3} into XMat;
read all var {y1 y2 y3} into YMat;
close;

/* write data in long form. Remember: matrices are written in row-major order */
create Want var {x y ID};
x = T(XMat);
y = T(YMat);
ID = row(x);
append;
close;

submit;
proc sgplot data=Want;
   series x=x y=y / group=ID;
run;
endsubmit;



&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jan 2023 11:40:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/854809#M5947</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-01-20T11:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using IML executefile() to execute SAS code written to an external file</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855000#M5948</link>
      <description>This is an excellent and appropriate solution, Ian, However, I want all processing to be performed within the scope of the module and using %include requires that I exit IML for the code to be executed.</description>
      <pubDate>Sun, 22 Jan 2023 15:35:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855000#M5948</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2023-01-22T15:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using IML executefile() to execute SAS code written to an external file</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855001#M5949</link>
      <description>Rick, I am familiar with the GROUP= option in PROC SGPLOT. I apparently am trying to exceed the bounds of PROC IML and will adopt the "wide-to-long" data transposition technique that you suggest. Thanks!</description>
      <pubDate>Sun, 22 Jan 2023 15:39:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855001#M5949</guid>
      <dc:creator>rbettinger</dc:creator>
      <dc:date>2023-01-22T15:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using IML executefile() to execute SAS code written to an external file</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855014#M5950</link>
      <description>&lt;P&gt;You're not "exceeding the bounds of PROC IML." You can construct multiple statements and send them into the SUBMIT block, but it is easier and simpler to use use the GROUP= option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, you accidentally selected your own response as the correct answer.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 11:17:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855014#M5950</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2023-01-23T11:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using IML executefile() to execute SAS code written to an external file</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855049#M5951</link>
      <description>&lt;P&gt;Well you could always 'submit' the include statement from within IML like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename pcode "&amp;amp;mypath\procprint_code.sas";

proc iml;
  file pcode;
  put 'proc print data=sashelp.class;';
  put 'run;';
  closefile pcode;

  submit;
    %include pcode;
  endsubmit;
quit ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 09:30:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Using-IML-executefile-to-execute-SAS-code-written-to-an-external/m-p/855049#M5951</guid>
      <dc:creator>IanWakeling</dc:creator>
      <dc:date>2023-01-23T09:30:43Z</dc:date>
    </item>
  </channel>
</rss>

