Hash Merge Error in SAS -
i trying create hash merge between 2 tables, output.hicno_xwalk
, , papi_claim_01
. before, had been doing normal match-merge using proc sorts , data step. here original code:
proc sort data = output.hicno_xwalk; hicnumber plan_type; run; proc sort data = papi_claim_01; hicnumber plan_type; run; data papi_claim_01a; merge output.hicno_xwalk (in=a) papi_claim_01 (in=b); hicnumber plan_type; if (b); run;
now, using this:
data hash_merge (drop = rc); set output.hicno_xwalk point = _n_; if 0 set output.hicno_xwalk papi_claim_01; *load properties; declare hash merge(dataset:'output.hicno_xwalk'); merge.definekey (hic); *define variable use key (no duplicates); merge.definedata ('new_hic','plan_type'); *columns merge table include; merge.definedone(); *end hash; until (eof); set papi_claim_01 end = eof; if merge.find() = 0 output; end; stop; *output records hic found in both tables; run;
however, error in log saying
error: type mismatch method parameter 1 @ line 404 column 5. error: expecting character type. error: data step component object failure.
aborted during execution phase.
what error trying tell me, , how fix code?
thanks help!
key variable name must quoted:
merge.definekey ('hic')
on note, i'm not sure what's purpose of code in data step (like option point
or do
loop stop
or multiple set
-statements same dataset), unless need other reasons, not shown in code snippet, hash merge can done simpler:
data hash_merge; set papi_claim_01; if 0 set output.hicno_xwalk; if _n_=1 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;
Comments
Post a Comment