1

Does anyone have any idea why I am getting the following error?

ERROR: Scalar cannot be converted to object of type hash.

the hash table has three columns and one row. I am loading it in a data step that has no set statement - see below:

data dataset1;
 imp='TOTAL';
 var1=3;
 var2=4;
run;

data test;
 call missing(var1,var2);
 declare hash imp(dataset:"dataset1 ");
 imp.defineKey('IMP');
 imp.defineData("VAR1","VAR2");
 imp.defineDone();
 imp='TOTAL';
 if imp.find() = 0 then PVIF= sum(var1, 2);
run;

can anyone advise?

flag

2 Answers

1

got it! was trying to use a variable with the same name as the hash table.

data dataset1;
 imp='TOTAL';
 var1=3;
 var2=4;
run;

data test;
 call missing(var1,var2);
 declare hash imp1(dataset:"dataset1 ");
 imp1.defineKey('IMP');
 imp1.defineData("VAR1","VAR2");
 imp1.defineDone();
 imp='TOTAL';
 if imp1.find() = 0 then PVIF= sum(var1, 2);
run;
link|flag
@NextLevel-IS, go ahead and accept your own answer (or mine :). – SAS-L Dec 16 at 16:27
1

I think you've already figured it out but...

your line: imp='TOTAL'; basically squashes your hash var and redefines it as a regular old Char variable.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.