<?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: Get list of all variables within a module as a variable in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Get-list-of-all-variables-within-a-module-as-a-variable/m-p/604843#M4912</link>
    <description>&lt;P&gt;I guess I'd use ODS OUTPUT to store the results of the SHOW command in a data set. Then read in the results and parse the file to obtain the variable name. Maybe this will give you are start (only partially tested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro PrintLocalVars();
   ods exclude iml.show; 
   ods output iml.show=showvars;   /* store SHOW table */
      show names;
   ods output close;
   ods exclude none;
   use showvars; read all var {batch}; close;
   call delete(showvars);
   _ndx = loc(batch^=' ');          /* delete any blank lines */
   if ncol(_ndx)&amp;gt;0 then batch=batch[_ndx];
   _b = batch[3:(nrow(batch)-1)];   /* get rid of  headers and end message */
   _LocalVars = scan(_b, 1, ' ');
   print _LocalVars;
   free batch _ndx _b _LocalVars;
%mend;

proc iml;

x = 1; y = 2; z = 3;
%PrintLocalVars();

free x y z varnames;
a = 1; b = 2; c = 3;
%PrintLocalVars();

/* get local vars inside module */
start example(input_var);
   var1 = input_var #2;
   var2 = input_var + 2;
   measure = var1 || var2;
   call execute("%PrintLocalVars()"); 
   return(measure);
finish;

M = {1,2};
test = example(M);

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 17 Nov 2019 21:25:56 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2019-11-17T21:25:56Z</dc:date>
    <item>
      <title>Get list of all variables within a module as a variable</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Get-list-of-all-variables-within-a-module-as-a-variable/m-p/604712#M4910</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to write code which executes some module, but in the same time automatically prints all variables/matrices or stores them in an excel sheet. For doing that, first I would need some functionality like "SHOW" which gives the local variables within the module, so that I can make a loop accross the variables and print and export them to excel. So in my opinion the key difficulty here is to get and store a list of all variables within a module. Is that possible with some IML functionalities?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;

start example(input_var);

var1 = input_var #2;
var2 = input_var + 2;

measure = var1 || var2;

return(measure)
finish;

M = {1,2};
test = example(M);

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In that example I would like to define a module or a macro with which I can execute the module "example" with additional requirement that while executing all local variables (so input, var1, var2, measure) are printed automatically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2019 16:46:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Get-list-of-all-variables-within-a-module-as-a-variable/m-p/604712#M4910</guid>
      <dc:creator>AThomalla</dc:creator>
      <dc:date>2019-11-16T16:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of all variables within a module as a variable</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Get-list-of-all-variables-within-a-module-as-a-variable/m-p/604719#M4911</link>
      <description>&lt;P&gt;I think, the answer is the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STORAGE Function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So first I would have to store all Matrices in a specific library (store _all_) and then apply the storage() function the get the list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2019 17:47:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Get-list-of-all-variables-within-a-module-as-a-variable/m-p/604719#M4911</guid>
      <dc:creator>AThomalla</dc:creator>
      <dc:date>2019-11-16T17:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get list of all variables within a module as a variable</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Get-list-of-all-variables-within-a-module-as-a-variable/m-p/604843#M4912</link>
      <description>&lt;P&gt;I guess I'd use ODS OUTPUT to store the results of the SHOW command in a data set. Then read in the results and parse the file to obtain the variable name. Maybe this will give you are start (only partially tested):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro PrintLocalVars();
   ods exclude iml.show; 
   ods output iml.show=showvars;   /* store SHOW table */
      show names;
   ods output close;
   ods exclude none;
   use showvars; read all var {batch}; close;
   call delete(showvars);
   _ndx = loc(batch^=' ');          /* delete any blank lines */
   if ncol(_ndx)&amp;gt;0 then batch=batch[_ndx];
   _b = batch[3:(nrow(batch)-1)];   /* get rid of  headers and end message */
   _LocalVars = scan(_b, 1, ' ');
   print _LocalVars;
   free batch _ndx _b _LocalVars;
%mend;

proc iml;

x = 1; y = 2; z = 3;
%PrintLocalVars();

free x y z varnames;
a = 1; b = 2; c = 3;
%PrintLocalVars();

/* get local vars inside module */
start example(input_var);
   var1 = input_var #2;
   var2 = input_var + 2;
   measure = var1 || var2;
   call execute("%PrintLocalVars()"); 
   return(measure);
finish;

M = {1,2};
test = example(M);

quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 17 Nov 2019 21:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Get-list-of-all-variables-within-a-module-as-a-variable/m-p/604843#M4912</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-11-17T21:25:56Z</dc:date>
    </item>
  </channel>
</rss>

