BookmarkSubscribeRSS Feed
gyambqt
Obsidian | Level 7

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?

1 REPLY 1
Kurt_Bremser
Super User

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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 976 views
  • 0 likes
  • 2 in conversation