Memory-Based SAS Libraries Characteristics & Important Notes
If data that is referenced or updated multiple times within a SAS session.
For PROC SORT that write multiple times to large temporary files.
To designate the Work library as memory-based, specify the MEMLIB system option when you start SAS.
Use MEMLIB option in the LIBNAME statement to designate a library as memory-based library.
All librefs, including a libref to the Work directory, must have a valid disk directory. a) After the library is designated as memory-based, your SAS program needs to copy the library from disk to memory. b) After processing the library in memory, the library must be copied back to disk.
Note: Copy the library that is in memory to disk after processing is complete. Failure to do so any changes made in library is lost. The changes are lost when the SAS session ends.
Example: Use of LIBNAME statement and the PROC COPY statement to copy a library to and from memory.
/* Set up two librefs, one to the library in memory */
/* and the other to the SAS library on disk. The library */
/* on disk contains dataset1, dataset2, dataset3 and dataset4. */
libname inmemory “g:\memlib” memlib;
libname ondisk “g:\disk”;
/* Copy dataset1, dataset2, dataset3, and dataset4 to memory */
proc copy in=ondisk out=inmemory;
/* …Assume dataset1 and dataset4 are updated */
/* Save the updated datasets back to disk */
proc copy in=inmemory out=ondisk;
select dataset1 dataset4;
You can also copy a data set to memory by using a DATA statement, as shown in the following example:
Part III: Using a Memory-Based Library as a SAS File Cache
Analytiks International Inc
4826 Chicago Ave S, Suite 102
Minneapolis, MN 55417