<?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: Terminating Lua via an Include statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739476#M230808</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;82   proc lua terminate;
83   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.15 seconds
      cpu time            0.00 seconds
      
84   proc lua terminate;
85   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
86   proc lua terminate;
87   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
88   proc lua terminate;
89   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
90   
91   &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;82   proc lua;
83   submit;
84   
85   local x = "Hello Local"
86   y = "Hello Global"
87   
88   endsubmit;
89   run;
NOTE: Resuming Lua state from previous PROC LUA invocation.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
90   
91   
92   proc lua;
93   submit;
94   
95   print(x)
96   print(y)
97   
98   endsubmit;
99   run;
NOTE: Resuming Lua state from previous PROC LUA invocation.
nil
Hello Global
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think we mark everything as local anyway so it might be completely fine. I had never actually tested that so thank you.&lt;/P&gt;</description>
    <pubDate>Thu, 06 May 2021 13:35:21 GMT</pubDate>
    <dc:creator>DLangley</dc:creator>
    <dc:date>2021-05-06T13:35:21Z</dc:date>
    <item>
      <title>Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739431#M230791</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to find out how to use the include statement to run Lua code that then terminates at the end to free up all of the memory.&lt;/P&gt;&lt;P&gt;This is the sort of thing that can be done via the call to proc lua as in this example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc lua terminate;
submit;

print("Hello World")

endsubmit;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But can this be done through the include statement as below?&lt;/P&gt;&lt;PRE&gt;%include "&amp;amp;filePath.\helloWorld.lua";&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 May 2021 09:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739431#M230791</guid>
      <dc:creator>DLangley</dc:creator>
      <dc:date>2021-05-06T09:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739443#M230793</link>
      <description>&lt;P&gt;Seems to work.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "&amp;amp;wdir\helloWorld.lua"; 
  put 'submit;';
  put 'print("Hello World")';
  put 'endsubmit;';
run;

proc lua terminate;
%include "&amp;amp;wdir\helloWorld.lua";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;46 proc lua terminate;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;47 %include "&amp;amp;wdir\helloWorld.lua";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NOTE: %INCLUDE (level 1) file K:\SASWORK\_TD19356_NZ8037SPSAS2003_\Prc2\helloWorld.lua is file &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;K:\SASWORK\_TD19356_NZ8037SPSAS2003_\Prc2\helloWorld.lua.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;48 +submit;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;49 +print("Hello World")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;50 +endsubmit;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NOTE: %INCLUDE (level 1) ending.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;51 run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;NOTE: PROC LUA is an experimental procedure.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NOTE: Lua initialized.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Hello World&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;NOTE: Lua terminated.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NOTE: PROCEDURE LUA used (Total process time):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;real time 0.02 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;user cpu time 0.00 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;system cpu time 0.01 seconds&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;memory 711.00k&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;OS Memory 28516.00k&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Timestamp 06/05/2021 10:21:08 PM&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;Step Count 1063 Switch Count 50&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 10:22:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739443#M230793</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-05-06T10:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739445#M230794</link>
      <description>&lt;P&gt;Thank you Chris.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Whilst that does work as part of an include statement it isn't quite the solution I was hoping for. I'll add more context in the hopes of getting there and thank you very much for your time already.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Later versions of SAS (9.4M+??) allow you to call pure lua code with just an include statement and without the proc lua wrapper. I think this is a wonderful innovation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* generate a lua file containing only lua code */
data _null_;
  file "&amp;amp;wdir\helloWorld.lua"; 
  put 'print("Hello World")';
run;

/* this runs the lua code by creating a lua instance */
%include "&amp;amp;wdir\helloWorld.lua";
/* this then resumes the instance */
%include "&amp;amp;wdir\helloWorld.lua";
/* this code would terminate the instance */
proc lua terminate;
run;
/* this code starts a new instance */
%include "&amp;amp;wdir\helloWorld.lua";

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My hope is that there is a system option or something that will enable the lua code called by the include statement to terminate. I tried seeing if there was something that could go in the include statement such as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%include "&amp;amp;wdir\helloWorld.lua" terminate;&lt;/PRE&gt;&lt;P&gt;But that does not work.&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 11:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739445#M230794</guid>
      <dc:creator>DLangley</dc:creator>
      <dc:date>2021-05-06T11:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739448#M230797</link>
      <description>&lt;P&gt;I don't think your example code will work at all.&lt;/P&gt;
&lt;P&gt;You have essentially asked SAS to run this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  file "&amp;amp;wdir\helloWorld.lua"; 
  put 'print("Hello World")';
run;
print("Hello World")
print("Hello World")
proc lua terminate;
run;
print("Hello World")&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That does not look like valid SAS code to me.&lt;/P&gt;
&lt;P&gt;Sounds like you want to run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc lua;
submit;
print("Hello World")
print("Hello World")
endsubmit;
submit;
print("Hello World")
endsubmit;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does that work?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If so then replace the LUA print() statements with the macro %INCLUDE statements.&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 11:27:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739448#M230797</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-06T11:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739458#M230802</link>
      <description>&lt;P&gt;Hi Tom.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That was my thought at first as well but according to&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p07wjwkog4ia54n1b7586zlzmxwe.htm#n0zo27qtnp9sehn1l9tule7q4z11" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p07wjwkog4ia54n1b7586zlzmxwe.htm#n0zo27qtnp9sehn1l9tule7q4z11&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class="xisDoc-paragraph"&gt;You can also run external Lua scripts (*.lua or *.luc files) by using the %INCLUDE statement in a SAS session. For example, to run the Lua script abc.luc, enter the following line in your SAS program:&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;%include "./tmp/abc.luc";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which I tested and does work in SAS Studio at least.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;83   /* this runs the lua code by creating a lua instance */
84   %include "helloWorld.lua";
NOTE: Lua initialized.
Hello World
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
93    /* this then resumes the instance */
94    %include "helloWorld.lua";
NOTE: Resuming Lua state from previous PROC LUA invocation.
Hello World
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
103   /* this code would terminate the instance */
104   proc lua terminate;
105   run;
NOTE: Resuming Lua state from previous PROC LUA invocation.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
106   /* this code starts a new instance */
107   %include "helloWorld.lua";
NOTE: Lua initialized.
Hello World
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
116   
117   
118 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;(I modified the include statement to remove the path but other than that this is a copy of the log)&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 12:24:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739458#M230802</guid>
      <dc:creator>DLangley</dc:creator>
      <dc:date>2021-05-06T12:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739464#M230804</link>
      <description>&lt;P&gt;So the question is about this special behavior that %INCLUDE is doing when the name of the text you are including happens to end with '.lua'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are the SAS log messages when you run the&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc lua terminate; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in a SAS session where you have never tried to run any LUA code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you have two %INCLUDEs of lua code next to each other is there some memory of the state of the LUA process between them?&amp;nbsp; For example can you reference values defined in the first include in the code of the second include?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there some LUA command that means get a clean slate that you could run?&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 12:34:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739464#M230804</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-06T12:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739467#M230805</link>
      <description>&lt;P&gt;I know next to nothing about LUA, but a quick scan of manual shows it does have a local construct.&amp;nbsp; So perhaps the solution is to have your %INCLUDE lua programs do everything in a local that disappears when they finish?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;do
  print("Hello World")
end&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 May 2021 12:45:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739467#M230805</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-06T12:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739473#M230807</link>
      <description>&lt;P&gt;Hi Tom.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you run and terminate by itself it does not cause any problems.&lt;/P&gt;&lt;P&gt;Yes Lua code can be passed between instances if they are not terminated but that memory is held the entire time which is not ideal.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suppose having everything as fully local might be a solution but that would require a lot of rewriting for us so we won't be going ahead with that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you though for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 13:23:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739473#M230807</guid>
      <dc:creator>DLangley</dc:creator>
      <dc:date>2021-05-06T13:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Terminating Lua via an Include statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739476#M230808</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;82   proc lua terminate;
83   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.15 seconds
      cpu time            0.00 seconds
      
84   proc lua terminate;
85   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
86   proc lua terminate;
87   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      
88   proc lua terminate;
89   run;
NOTE: Lua initialized.
NOTE: TKLua terminated.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
90   
91   &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;82   proc lua;
83   submit;
84   
85   local x = "Hello Local"
86   y = "Hello Global"
87   
88   endsubmit;
89   run;
NOTE: Resuming Lua state from previous PROC LUA invocation.
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
90   
91   
92   proc lua;
93   submit;
94   
95   print(x)
96   print(y)
97   
98   endsubmit;
99   run;
NOTE: Resuming Lua state from previous PROC LUA invocation.
nil
Hello Global
NOTE: PROCEDURE LUA used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think we mark everything as local anyway so it might be completely fine. I had never actually tested that so thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 13:35:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Terminating-Lua-via-an-Include-statement/m-p/739476#M230808</guid>
      <dc:creator>DLangley</dc:creator>
      <dc:date>2021-05-06T13:35:21Z</dc:date>
    </item>
  </channel>
</rss>

