/***************************************************************************************************************** SAS file name: suminc_keysum.sas File location: __________________________________________________________________________________________________________________ Purpose: To demonstrate how to use the Suminc and Keysum Arguments in the SAS Hash Object Author: Peter Clemmensen Creation Date: This program supports the blog post "Using Suminc and Keysum in SAS Hash Object" on SASnrd.com *****************************************************************************************************************/ /* Suminc */ data _null_; declare hash h (suminc : 's'); h.definekey ('k'); h.definedone (); k = 1; s = 2; h.add (); /* Initializes the key summary to 2 */ h.sum (sum : t); put "After Add() Method: " @25 t =; h.check (); /* Increments the key summary to 4 */ h.sum (sum : t); put "After Check() Method: " @25 t =; h.find (); /* Increments the key summary to 4 */ h.sum (sum : t); put "After Find() Method: " @25 t =; h.replace (); /* Re-Initializes the key summary to s = 2 */ h.sum (sum : t); put "After Replace() Method: " @25 t =; run; /* Keysum */ data _null_; declare hash h (suminc : 's', keysum : 'keysum'); h.definekey ('k'); h.definedone (); k = 1; s = 2; keysum = 0; h.add (); h.ref (); h.ref (); h.find (); h.find (); h.output (dataset : 'test'); run;