09-26-2014 10:51 AM
I am receiving this error for my hash portion of my code:
ERROR: Type mismatch for method parameter 1 at line 31 column 3.
ERROR: Expecting Character type.
ERROR: DATA STEP Component Object failure. Aborted during the EXECUTION phase.
This is my code:
if _n_=1 then do;
declare hash e(dataset:'myasiq.student_dim');
My student_skey is a numeric field and student_id is character. I am not sure what is generating the error.
09-26-2014 11:31 AM
Two thoughts: (1) Does the code preceding the code you posted include length statements for student_skey and student_id? and (2) have you tried to put quotes around student_skey (i.e., 'student_skey)?
09-26-2014 11:47 AM
The defineData and defineKey methods need a char argument.
It is also very important to define the variables from the hash object also in the PDV.
See an example below:
09-26-2014 12:15 PM
I think the un-executed SET statement may be useful here. That way you don't have to know what the attributes are and they are not hard coded into your program. You will need STOP statement however.
09-26-2014 02:32 PM
I think what gets you confused is the 'variable name' and 'variable type' in the Hash definition. The quoted notion such as 'student_skey' in e.definekey('student_skey'); has nothing to do with the 'variable type', it merely addresses the 'variable name', where the variable can be either Char or Num, defined by incoming table or PDV. See following example,
if _n_=1 then
if 0 then
declare hash h(dataset: 'sashelp.class');
So quoted or not merely saying whether it is a 'string' or a variable. If it is a 'string', then 'string' itself is the variable name, if not quoted (variable), the content of the variable is the variable name.