DATA Step, Macro, Functions and more

length statement in Hash table

Reply
Regular Contributor
Posts: 152

length statement in Hash table

Hello Experts,

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?

Super User
Posts: 6,977

Re: length statement in Hash table

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 1 reply
  • 147 views
  • 0 likes
  • 2 in conversation