<?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: DO loop to save in-memory tables in Developers</title>
    <link>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/610792#M611</link>
    <description>&lt;P&gt;Thank you so much! This solution worked perfectly.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Dec 2019 18:21:47 GMT</pubDate>
    <dc:creator>mpg</dc:creator>
    <dc:date>2019-12-10T18:21:47Z</dc:date>
    <item>
      <title>DO loop to save in-memory tables</title>
      <link>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/609512#M609</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to write a program on Viya to save all in-memory tables in a particular set of caslibs. I have written code that can identify the caslibs and iterate through them to do something (for now, just print the names of the tables).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cas;
	table.caslibinfo result=caslibs / active=false srcType="PATH" showHidden=true;
	caslibNames = caslibs.caslibinfo.where(Name LIKE 'text%')[,'Name'];
	do name over caslibNames;
		print name;   /* show current caslib name */
		table.tableInfo result=tables / caslib=name;	
		if tables[1] ne . then do;   /* if statement skips caslibs that have no tables */
			tableNames = tables.tableInfo[,'Table Name'];
			do name over tableNames;
				print name;   /* show table name, replace with code to save table */
			end;
	end;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I've been looking at the table.save action, but I can't figure out how to programatically specify the caslib and table names based on where the program currently is in the do loops.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any advice would be welcomed! Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 20:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/609512#M609</guid>
      <dc:creator>mpg</dc:creator>
      <dc:date>2019-12-04T20:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop to save in-memory tables</title>
      <link>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/610648#M610</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I made some changes to your code to return full information for cas libraries and cas tables. I then added the table.save action.&lt;/P&gt;
&lt;P&gt;The table.save action will save a table (in memory) to the physical location of the same cas library. For testing purposes I haved added "2" at the end of the filename.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cas sugus sessopts=(caslib="casuser");

/*
 * create some test data in casuser
 */
libname casuser cas caslib="casuser";

data casuser.mycars(replace=yes) casuser.mycars_a(replace=yes);
  set sashelp.cars;
run;
data casuser.myclass(replace=yes);
  set sashelp.class;
run;

proc cas;
  table.caslibinfo result=caslibs /  srcType="PATH" ;
  caslibNames = caslibs.caslibinfo.where(Name LIKE 'CASUSER%');
  
  do currentCaslib over caslibNames;
    print "NOTE: currentCaslib=" currentCaslib.name;   /* show current caslib name */
     
    table.tableInfo result=tables / caslib=currentCaslib.name; 
    
    if exists(tables, 'TableInfo') then do;   /* if statement skips caslibs that have no tables */
      tableNames = tables.tableInfo;      
      do currentCastable over tableNames;
        print "NOTE: currentCastable=" currentCastable.name;   /* show table name, replace with code to save table */
        action table.save / 
          /* source caslib and table name */
          table={
            caslib=currentCaslib.name
            name=currentCastable.name   
          }
          /* target caslib and filename info */
          caslib=currentCaslib.name
          name=cats(currentCastable.name, "2")
          replace=true
        ;
      end;
      /*
       * check for files being written
       */
      action table.fileinfo / caslib=currentCaslib.name allFiles=TRUE ;
    end;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Dec 2019 09:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/610648#M610</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2019-12-10T09:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop to save in-memory tables</title>
      <link>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/610792#M611</link>
      <description>&lt;P&gt;Thank you so much! This solution worked perfectly.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2019 18:21:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/610792#M611</guid>
      <dc:creator>mpg</dc:creator>
      <dc:date>2019-12-10T18:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop to save in-memory tables</title>
      <link>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/691623#M987</link>
      <description>Bruno_SAS ,  &lt;BR /&gt;&lt;BR /&gt;I have the exact same situation. I tried to use your code but it will not go inside the "if exists(tables, 'TableInfo') then do;" condition.&lt;BR /&gt;If  I use print tables;  the result shows some tables. if I comment the if statement the code works like a charm.&lt;BR /&gt;&lt;BR /&gt;Any suggestions why the if statement might be failing ?  is there any documentation for the results format  for table actions &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks &lt;BR /&gt;Yatin Rao  &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Oct 2020 18:43:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/691623#M987</guid>
      <dc:creator>yatinrao</dc:creator>
      <dc:date>2020-10-14T18:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: DO loop to save in-memory tables</title>
      <link>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/691753#M988</link>
      <description>&lt;P&gt;Yatin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest to open a new discussion and provide your code sample with the log, this will help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 06:07:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/DO-loop-to-save-in-memory-tables/m-p/691753#M988</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2020-10-15T06:07:35Z</dc:date>
    </item>
  </channel>
</rss>

