peterpan_aus 发表于 2012-1-17 19:12 
这是用proc sql写的
proc sql;
update cr_postpay2a as u
最好有实际数据。/*another method*/
proc sort data=total_calls
nodupkey
out=total_calls_sorted(keep=charged_party_number hours_flag total_call
rename=(tatal_call=total_call_v2))
;
by charged_party_number
hours_flag
;
run;
data cr_postpay2a_v2;
if _n_=1 then do;
if 0 then set total_calls_sorted;
declare hash
ht(dataset: "total_calls_sorted");
ht.definekey("charged_party_number",
"hours_flag");
ht.definedata("total_call_v2");
ht.definedone();
end;
set cr_postpay2a;
rc=ht.find(key: charged_party_number,
key: hours_flag);
if rc=0 then total_call=total_call_v2;
else total_call_v2=.;
drop rc total_call_v2;
run;