Hi, According to the documentation (link from @Scott Bass): If the data set contains duplicate keys, by default, the first instance is stored in the hash object; subsequent instances are ignored. To store the last instancein the hash object, use the DUPLICATE argument tag. The DUPLICATE argumenttag also writes an error to the SAS log if there is a duplicate key. Actually, what I meant was, you need to understand the difference between: declare Hash H(dataset: "dates"); H.DefineKey ('number'); H.DefineData ('date'); H.DefineDone (); /* complete hash table definition */ And (untested): declare Hash H(); H.DefineKey ('number'); H.DefineData ('date'); do until (eof); set dates end=eof; H.Add(); end; H.DefineDone (); /* complete hash table definition */ And: declare Hash H(); H.DefineKey ('number'); H.DefineData ('date'); do until (eof); set dates end=eof; H.Replace(); end; H.DefineDone (); /* complete hash table definition */ Assuming a sorted order of your keys, I view Add() as "keep the first occurence" and Replace() as "keep the last occurence" of the key value. Somewhat analogous to first. and last. processing (just an analogy, not identical!) I didn't read the finer points of the original post, so this knowledge may or may not be relevant, but it's good to know regardless. I have sometimes used two hash objects, the first to "de-dup", or otherwise get my desired data into a hash, and the second hash object (using different keys) to return the data in desired sort order. Regards, Scott
... View more