data Matched(keep= IdSelectedControl MatchedToTreatID);
if _N_= 1 then do;
if 0 then set Control;
declare hash h(dataset: "Control", ordered: 'no');
declare hiter iter('h');
h.defineKey('idC','k2');
h.defineData(all:"yes");
h.defineDone();
call missing(idC, pscoreC);
end;
set Treatment;
retain BestDistance 99;
rc= iter.first();
if (rc=0) then BestDistance= 99;
do while (rc= 0);
if k1=k2 then do;
ScoreDistance= abs(pscoreT - pscoreC);
if ScoreDistance < BestDistance then do;
BestDistance= ScoreDistance;
IdSelectedControl= idC;
MatchedToTreatID= idT;
MatchedK=k2;
end;
end;
rc= iter.next();
if (rc~= 0) then do;
output;
rc1= h.remove(key: IdSelectedControl,key:MatchedK);
end;
end;
run;作者: shiyiming 时间: 2011-1-25 19:48 标题: Re: sas中的哈希表 thanks!作者: shiyiming 时间: 2011-3-7 09:50 标题: Re: sas中的哈希表 hash 可以实现两组间的匹配,那三组和三组以上的匹配该怎样实现?