I'm able to declare 1 hash table like this:
data DALY1;
* set lengths ;
length Germ $10 Category1 $50 Category2 $50 AgeGroupDALY $10 Gender $2 value 8;
* make link to hash table ;
if _n_=1 then do;
declare hash h1(dataset:'modelData');
h1.definekey ('Germ', 'Category1', 'Category2', 'AgeGroupDALY', 'Gender') ;
h1.definedata('Value');
h1.definedone();
call missing(Germ, Value, Category1, Category2);
end;
run;
but when I declare 2 like this:
data DALY1;
* set lengths ;
length Germ $10 Category1 $50 Category2 $50 AgeGroupDALY $10 Gender $2 value 8;
* make link to hash table ;
if _n_=1 then do;
declare hash h1(dataset:'modelData');
h1.definekey ('Germ', 'Category1', 'Category2', 'AgeGroupDALY', 'Gender') ;
h1.definedata('Value');
h1.definedone();
call missing(Germ, Value, Category1, Category2);
declare hash h2(dataset:'states');
h2.definekey ('Germ') ;
h2.definedata('stateList');
h2.definedone();
end;
run;
I get:
ERROR: Undeclared data symbol stateList for hash object at line 194 column 3.
ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.
I'm wondering if it is even possible to declare 2 hash tables (or more, I will need 3) at the same time.
If the answer is yet, what am I doing wrong?
I can't find any example of this anywhere.
Thanks!
Yes, you can create multiple Hash tables in one DATA STEP.
Refer to: This Forum Paper or This SESUG paper
You did not define the variable 'stateList'. Add the variable 'stateList' to your LENGTH statement.