SAS 中的哈希合并错误
Hash Merge Error in SAS
我正在尝试在两个表 output.hicno_xwalk
和 papi_claim_01
之间创建散列合并。之前,我一直在使用过程排序和数据步骤进行正常的匹配合并。原代码如下:
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;
现在,我正在使用这个:
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;
但是,我在日志中收到一条错误消息说
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.
试图告诉我的错误是什么,我该如何修复我的代码?
感谢您的帮助!
关键变量名必须用引号引起来:
merge.definekey ('HIC')
另一方面,我不确定您的数据步骤中某些代码的目的是什么(例如选项 point
或 do
循环 stop
或多个 set
-statements for the same dataset), 但除非你出于其他原因需要它,没有在你的代码片段中显示,哈希合并可以更简单地完成:
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;
我正在尝试在两个表 output.hicno_xwalk
和 papi_claim_01
之间创建散列合并。之前,我一直在使用过程排序和数据步骤进行正常的匹配合并。原代码如下:
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;
现在,我正在使用这个:
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;
但是,我在日志中收到一条错误消息说
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.
试图告诉我的错误是什么,我该如何修复我的代码?
感谢您的帮助!
关键变量名必须用引号引起来:
merge.definekey ('HIC')
另一方面,我不确定您的数据步骤中某些代码的目的是什么(例如选项 point
或 do
循环 stop
或多个 set
-statements for the same dataset), 但除非你出于其他原因需要它,没有在你的代码片段中显示,哈希合并可以更简单地完成:
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;