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?
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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.