<?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: Juletip #1 – Load several files to CAS in SAS Community Nordic</title>
    <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-1-Load-several-files-to-CAS/m-p/979756#M506</link>
    <description>&lt;P&gt;Brilliant tip Jussi, this will save people a lot of time!&lt;/P&gt;</description>
    <pubDate>Mon, 01 Dec 2025 09:49:41 GMT</pubDate>
    <dc:creator>IainBrown</dc:creator>
    <dc:date>2025-12-01T09:49:41Z</dc:date>
    <item>
      <title>Juletip #1 – Load several files to CAS</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-1-Load-several-files-to-CAS/m-p/979752#M505</link>
      <description>&lt;P&gt;When working with SAS Viya you will eventually run into situations where the dataset you've worked with has dropped from CAS memory to a file in the CASLIB- library. In order to load the file or files back to memory, you typically need to list the names of the files with CASUTIL- procedure to find out the actual names of these files. And then you need ro re-run the same CASUTIL- procedure in order to load the files to memory using their full names including the correct suffixes. If you are like me, you end up copy-pasting all the names needed from Log- window to program editor one at the time. And, if you are like me, you never remember to promote the tables and you do this yet one more time.&lt;/P&gt;
&lt;P&gt;One feature I've been missing in CASUTIL- procedure is that it would be really nice if I could load all files with some specific text in the file name with one go. For example, I would like to load all my ABT- tables from files to memory.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've now done a SAS Macro called LoadToCAS which loads all files contaiting a specific text from files to CAS memory.&amp;nbsp; The default CASlib is PUBLIC, but it can be over-ridden.&lt;/P&gt;
&lt;P&gt;Examples:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;%LoadToCAS(TableNamesWith="HMEQ_");&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;- macro call would load all files in PUBLIC -caslib containing text "HMEQ_" to memory.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;%LoadToCAS(CASLIB=CASUSER, TableNamesWith="ABT_");&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;- macro call would load all files in CASUSER -caslib containing text "ABT_" to memory.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro LoadToCAS(CASLIB=PUBLIC, TableNamesWith="");
/* 
This SAS Macro loads the wanted files from files to CAS. The default CASLIB- is PUBLIC, but
it can be overridde by the macro's CASLIB- parameter.
This Macro loads all files containing the example text in TableNamesWith- parameter. 
Note! TableNamesWith- parameter should be provided within the douple quotes.

Ex1. %LoadToCAS(TableNamesWith="HMEQ_");
- macro call would load all files in PUBLIC -caslib containing text "HMEQ_" to memory.

Ex2. %LoadToCAS(CASLIB=CASUSER, TableNamesWith="ABT_");
- macro call would load all files in CASUSER -caslib containing text "ABT_" to memory.
*/

/* Let's capture the file listing of CASUTIL- procedure. */
ods output FileInfo=FileInfo;

proc casutil incaslib= &amp;amp;CASLIB.;
    list files;
run;

/* Create a dataset containing all rows with the table names we want. */
/* Also, count the number of rows. */
data WORK._FILES;
    set WORK.FILEINFO;
    where Name contains &amp;amp;TableNamesWith.;
    call symput("_CASDATA_" || left(put(_N_, 4.)), compress(Name));
    call symput("_CASOUT_" || left(put(_N_, 4.)), compress(scan(Name, 1, ".")));
    call symput("_N_", _N_);
run;

/* Loop the rows and load the wanted files to CAS. */
proc casutil incaslib= &amp;amp;CASLIB. outcaslib= &amp;amp;CASLIB.;
%do i = 1 %to &amp;amp;_N_.;
    load casdata="&amp;amp;&amp;amp;_CASDATA_&amp;amp;i.." CASOUT="&amp;amp;&amp;amp;_CASOUT_&amp;amp;i.." promote;
%end;    
run;

%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2025 07:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-1-Load-several-files-to-CAS/m-p/979752#M505</guid>
      <dc:creator>JussiV</dc:creator>
      <dc:date>2025-12-01T07:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Juletip #1 – Load several files to CAS</title>
      <link>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-1-Load-several-files-to-CAS/m-p/979756#M506</link>
      <description>&lt;P&gt;Brilliant tip Jussi, this will save people a lot of time!&lt;/P&gt;</description>
      <pubDate>Mon, 01 Dec 2025 09:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Community-Nordic/Juletip-1-Load-several-files-to-CAS/m-p/979756#M506</guid>
      <dc:creator>IainBrown</dc:creator>
      <dc:date>2025-12-01T09:49:41Z</dc:date>
    </item>
  </channel>
</rss>

