04-07-2015 10:33 PM
I understand length statement is adding key items and data items defined in Hash object to the Program Data Vector so they can be treated as Data step variables so SAS can retrieve relevant records based on the key value and place it the corresponding DATA step variable in the PDV.
My question is, in terms of loading the hash object with the SAS data, does the length statement also help to build a link between hash key and data items and dataset variables that you want to load into the hash, in other words, SAS won't be able to load the hash object with the SAS data without length statement?
04-08-2015 02:25 AM
No. The length statement is just used so that the hash variables have the right attributes.
How the keys are used is defined later in the data step. IE you can load the key variable with a value and use x.find() (x being the name of your hash object) to determine if such a key is in your hast object.
Or you could define the hash object key exactly like one of your dataset variables (same name), then you only need to use the find() function because the value is automatically loaded when the dataset record is read.