Reputation: 49
I am trying to create a hash merge between two tables, output.hicno_xwalk
, and papi_claim_01
. Before, I had been doing a normal match-merge using proc sorts and a data step. Here is the original code:
proc sort data = output.hicno_xwalk;
by HICNUMBER Plan_Type;
run;
proc sort data = papi_claim_01;
by HICNUMBER Plan_Type;
run;
data papi_claim_01a;
merge output.hicno_xwalk (in=a)
papi_claim_01 (in=b);
by HICNUMBER Plan_Type;
if (b);
run;
Now, I am using this:
data hash_merge (drop = rc);
set output.hicno_xwalk point = _n_;
if 0 then set output.hicno_xwalk papi_claim_01; *load properties;
declare hash merge(dataset:'output.hicno_xwalk');
merge.definekey (HIC); *define variable to use as a key (no duplicates);
merge.definedata ('NEW_HIC','Plan_Type'); *Columns from the merge table to include;
merge.definedone(); *end hash;
do until (eof);
set papi_claim_01 end = eof;
if merge.find() = 0 then output;
end;
stop; *output records where HIC is found in both tables;
run;
However, I get an error in my log saying
ERROR: Type mismatch for method parameter 1 at line 404 column 5. ERROR: Expecting Character type. ERROR: DATA STEP Component Object failure.
Aborted during the EXECUTION phase.
What is the error trying to tell me, and how do I fix my code?
Thanks for the help!
Upvotes: 0
Views: 934
Reputation: 1763
Key variable name must be quoted:
merge.definekey ('HIC')
On another note, I'm not sure what's the purpose of some code in your DATA step (like option point
or do
loop with stop
or multiple set
-statements for the same dataset), but unless you need it for some other reasons, not shown in your code snippet, just hash merge can be done much simpler:
data hash_merge;
set papi_claim_01;
if 0 then set output.hicno_xwalk;
if _n_=1 then do; *to avoid re-creating hash-object every time;
declare hash merge(dataset:'output.hicno_xwalk');
merge.definekey ('HIC');
merge.definedata ('NEW_HIC','Plan_Type');
merge.definedone();
end;
if merge.find() = 0;
run;
Upvotes: 1