BookmarkSubscribeRSS Feed
mathias
Quartz | Level 8

 

 

Hello,

 

I'm just beginning to use hash tables and I have the impression that find() only work once per oberservation.

I don't understand how this come.

 

EDIT: I just found out that rc2=160038

 

 

This is my hash table declaration

 

	if _n_=1 then do;

		***modelvalues ----------------;
		declare hash h1(dataset:'modelData');
		h1.definekey ('Germ', 'Category1', 'Category2', 'AgeGroupDALY', 'Gender') ;
		h1.definedata('Value');
		h1.definedone();
		call missing(Germ, Value, Category1, Category2);
		* e.g. rc=h1.find(KEY:Germ, KEY:"State", KEY:"property", KEY:AgeGroupDALY, KEY:Gender);

	end;

I'm able to find a value, but if I do a second lookup with find() with other keys, 'value' doesn't change like it should be.

It's like the second find doesn't even work or doesnt override 'value'.

 

		rc=h1.find(KEY:Germ, KEY:Edge, KEY:"Probability", KEY:AgeGroupDALY, KEY:Gender);
		put "value=" value;
		rc2=h1.find(KEY:Germ, KEY:Edge, KEY:"Probability", KEY:"0", KEY:"M");
		put "value=" value;

Do I need to close the connection or do something special?

 

Thank you

 

 

1 REPLY 1
Ksharp
Super User
Remember Put CALL MISSING() before each and every FIND() to avoid the error result.



call missing(Value);  /* <---- No need to call missing KEY variable, Only DATA variable   */
rc=h1.find(KEY:Germ, KEY:Edge, KEY:"Probability", KEY:AgeGroupDALY, KEY:Gender);
put "value=" value;

call missing(Value);
rc2=h1.find(KEY:Germ, KEY:Edge, KEY:"Probability", KEY:"0", KEY:"M");
put "value=" value;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1229 views
  • 1 like
  • 2 in conversation