/***************************************************************************************************************** SAS file name: memrc.sas File location: __________________________________________________________________________________________________________________ Purpose: To investigate the memrc option in the Definedone method of the hash object. Author: Peter Clemmensen Creation Date: 15/01/2020 This program supports the blog post "The Hash Object Memrc Option in Definedone - SASnrd.com" on SASnrd.com *****************************************************************************************************************/ /* Find the available memory and real (non-pagable) memory */ proc options option=(memsize realmemsize); run; /* Create a dataset bigger than the real memory */ data big; do x = 1 to 1e9; output; end; run; /* The Memrc Option returns a non-zero return code and frees the underlying memory if the hash objecr exceeeds memory */ data _null_; declare hash h (dataset : 'big'); h.definekey ('x'); rc = h.definedone (memrc : 'y'); put rc = ; x = .; run; /* The documentation says that the only allowable operation after a nonzero return code with Memrc is the delete method. However, this is true only for that instance of h. We are allowed to create a new instance of h and work with that */ data big; do x = 1 to 1e9; output; end; run; data small; do x = 1 to 10; output; end; run; data _null_; declare hash h (dataset : 'big'); h.definekey ('x'); rc = h.definedone (memrc : 'y'); put rc =; h = _new_ hash (dataset:'small'); h.definekey ('x'); rc = h.definedone (memrc:'y'); put rc =; x = 1; rc = h.find (); run;