/***************************************************************************************************************** SAS file name: hashobject_size File location: _________________________________________________________________________________________________________________ Purpose: To demonstrate how to measure the memory comsumption of a hash object in SAS Author: Peter Clemmensen Creation Date: 18/11/2018 This program supports the example page "How Much Memory Does SAS Hash Object Occupy?" on SASnrd.com *****************************************************************************************************************/ /* Create example data */ data MyData; do x=1 to 10e6; output; end; run; /* Check hash object memory consumption */ data _null_; if 0 then set MyData; before=input(getoption('xmrlmem'),20.); if _N_=1 then do; declare hash h(dataset:"MyData", hashexp:0); h.defineKey('x'); h.defineDone(); end; after=input(getoption('xmrlmem'),20.); hashsize=before-after; put "Hash Object Takes Up:" hashsize sizekmg10.2; run; /* Check empty hashobject size */ data _null_; k=.; before=input(getoption('xmrlmem'), 20.); if _N_ = 1 then do; declare hash h(hashexp:20); h.defineKey('k'); h.defineDone(); end; after=input(getoption('xmrlmem'), 20.); hashsize=before-after; put "Hash Object Takes Up:" hashsize sizekmg.; run;