这个sas代码应该在每次迭代时更新raf,然后将新的raf值相乘以创建更新的est_bign。但是raf值没有更新。我已经删除了它们,因此节省了空间。
This is how it is now:
est_bign_r raf
207640.2 1.002402
207640.2 1.002402
This is how is should be:
207640.17 1.0024
219236.92 0.94938
Here is the full code:
data &dsource..initial_raf
hold_output3_orig ;
set &dsource..begin_raf;
by tow cgroup_raf cell_raf;
i_rake = 1; /* First N_RAKE loop */
array comp_int[0:2] $1 comp_int_0-comp_int_2;
array post_naf_wgt[0:&repnum] 8 post_naf_wgt0-post_naf_wgt&repnum; /* rep_cnt */
array estbignr[0:&repnum] 8 estbignr0-estbignr&repnum;
array bign_r_rep[0:&repnum] 8 bign_r_0-bign_r_&repnum;
array raf_factors[&r_start:&n_ratio,0:&repnum] 8;
length check_raf $3 count_r 8;
retain estbignr0-estbignr&repnum count_r 0;
if first.cell_raf then
do;
call missing(of estbignr0-estbignr&repnum);
count_r = 0;
end;
if (elig_hu eq '1') then
do;
if (comp_int[tow] eq '1') then /* interview */
do;
do rep_cnt = 0 to &repnum;
%if (&raf_val eq &r_start) %then
%do;
estbignr[rep_cnt] + (post_naf_wgt[rep_cnt] * 1 * z_r * elig_r);
%end;
%else %do;
%let raf_neg = %eval(&raf_val-1);
estbignr[rep_cnt] + (post_naf_wgt[rep_cnt] *
raf_factors[&raf_neg,rep_cnt] * z_r * elig_r);
%end;
end;
count_r + elig_r;
end;
end;
if (last.cell_raf) then
do;
r = &raf_val; /* R value (1 to N_RATIO) */
/* calculate initial RAF value */
do rep_val = 0 to &repnum;
if (estbignr[rep_val] lt 0) then estbignr[rep_val] = 0;
if (estbignr[rep_val] eq 0) then raf=42;
else raf = bign_r_rep[rep_val] / estbignr[rep_val];
/* ?? Correct version
raf = bign_r / estbignr[rep_val];
collapse_raf = '1'; /* flag for before collapsing */
est_bign_r = estbignr[rep_val];
bign_r = bign_r_rep[rep_val];
if (raf lt 0.5) or (raf gt 2) or (count_r lt 25)
then check_raf = "bad";
else check_raf = "ok";
if (rep_val eq 0) then output &dsource..initial_raf;
output hold_output3_orig;
end;
end;
run;