BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
rbettinger
Lapis Lazuli | Level 10

I have created a SAS/IML library with scores of modules using SAS/Studio OnDemand. I want to download this library to my Windows 11 PC. I used the SAS/Studio download function to send the file to my PC, where it was received successfully. But when I try to access it using the following code:

 

libname Subtract 'C:\Users\RossMaster\Documents\My SAS Files\Subtractive Clustering\SASCode' ;                                          

proc iml ;
reset storage=Subtract.fuzzylib ;

show storage ;
quit ;

then the process fails because PC SAS does not recognize the contents of the library. Do I use PROC ENCODE to encode the library for transport in SAS/Studio and then use PROC DECODE to create a new library on the PC? Is there another way?

Ross

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

When you create an IML library of functions, you start with the SOURCE CODE, which is the set of text files that contains the module definitions. When you use the STORE statement, the source code is compiled and stored in binary form in a SAS catalog. SAS catalogs are not compatible across operating systems or releases, which means that you cannot transfer a catalog compiled on Linux under some SAS release and expect to read it on Windows in another SAS release. 

 

What you should do is transfer the SOURCE CODE files to your PC. Read them into PROC IML and use the STORE statement to create a catalog for your Windows 11 PC.

View solution in original post

5 REPLIES 5
Rick_SAS
SAS Super FREQ

When you create an IML library of functions, you start with the SOURCE CODE, which is the set of text files that contains the module definitions. When you use the STORE statement, the source code is compiled and stored in binary form in a SAS catalog. SAS catalogs are not compatible across operating systems or releases, which means that you cannot transfer a catalog compiled on Linux under some SAS release and expect to read it on Windows in another SAS release. 

 

What you should do is transfer the SOURCE CODE files to your PC. Read them into PROC IML and use the STORE statement to create a catalog for your Windows 11 PC.

rbettinger
Lapis Lazuli | Level 10

Thanks, Rick. I will use your approach. Because I have lots of modules to compile, is there any easy way that I can compile each module and store it in a SAS/IML library? Or do I need to run SAS/IML on each individual file containing a module definition?

Ross

Rick_SAS
SAS Super FREQ

There are several ways to organize a library of functions. Back in 2013, I wrote this article: How to create a library of functions in PROC IML - The DO Loop

I am going to guess that you have dozens of physical files, which I will call Def1.sas, Def2.sas, Def3.sas, etc.  The two main ways to organize the code is

 

  • Each file starts with PROC IML, defines the functions, uses the STORE statement to save them, and then QUITs. In this organization, you would %include the relevant files OUTSIDE of your main program, then use LOAD to load the modules inside the main program.
  • No file contains PROC IML or QUIT, only the module definitions and a STORE statement. To use the functions, you can %include them directly into a program *OR* you can create a driver program that starts with PROC IML, includes the definitions, and then does one QUIT.

I tend to use the second method because I can work on and test components independently. So, here's the way I usually do it:

/* ------ Def1.sas FILE ----- */
start MyMod1(x);  ... finish;
start MyMod2(x);  ... finish;
start MyMod3(x);  ... finish;
store module = (
MyMod1
MyMod2
MyMod3
);

 

/* ------ Def2.sas FILE ----- */
start MyMod4(x);  ... finish;
start MyMod5(x);  ... finish;
start MyMod6(x);  ... finish;
store module = (
MyMod4
MyMod5
MyMod6
);

/* ------ DefineAll.sas FILE ----- */
%let path = path/to/my/modules;
proc iml;
%INCLUDE "&path/Def1.sas";
%INCLUDE "&path/Def2.sas";
QUIT;

Then, when I want to use the modules, I do this:

 

 

%include "DefineAll.sas";  /* stores all modules */
proc iml;
load module=_all_;
y = MyMod1(1234);
z = MyMod6(4321);

 

 

 

rbettinger
Lapis Lazuli | Level 10
Very nice solution, Rick. Thanks.
Ksharp
Super User
One way you could try is:
1) Run PROC CPORT to export your IML library into a XPT file.
2)Download this XPT file.
3)Use PROC CIMPORT to import this XPT file at your Windows PC side.