/***************************************************************************************************************** SAS file name: hash_assigned_unassigned File location: _________________________________________________________________________________________________________________ Purpose: To demonstrate the difference between the assigned and unassigned hash object method call in SAS. Author: Peter Clemmensen Creation Date: 04/04/2019 This program supports the example page "Assigned Vs Unassigned Hash Object Method Call in SAS" on SASnrd.com *****************************************************************************************************************/ /* An unassigned Add() Method call. */ data _null_; k=.; d=.; declare hash h(); h.defineKey('k'); h.defineData('d'); h.defineDone(); h.add(key:2, data:2); h.add(key:2, data:4); run; /* An assigned Add() Method call. */ data _null_; k=.; d=.; declare hash h(); h.defineKey('k'); h.defineData('d'); h.defineDone(); rc=h.add(key:2, data:2); put rc=; rc=h.add(key:2, data:4); put rc=; run; /* It doesn't matter whether we call the clear method assigned, the data step will stop executing if the object is locked by an iterator */ data _null_; k=.; d=.; declare hash h(); h.defineKey('k'); h.defineData('d'); h.defineDone(); declare hiter hi('h'); rc=h.add(key:2, data:2); hi.first(); h.clear(); *h.delete(); run;