- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I have the following code which I need to decode and will require the communities help to understand if my thinking is correct. Here's the code:
data facilities(index=(obk fack))
f_xclud
;
format arrival_dt_system last_dt date9.;
length cd_base_id $6. cm_ind_l2 $25.;
if _n_ eq 1 then do;
declare hash nai (dataset:"D_industry");
nai.definekey ('ind_gen_id');
nai.definedata ('cd_base_id','cm_ind_l2');
nai.definedone ();
call missing(cd_base_id, cm_ind_l2);
declare hash arv (dataset:"f_a_dt");
arv.definekey ('ps_o_id', 'ps_s_id ', 'ps_f_id');
arv.definedata ('arrival_dt_system', 'last_dt');
arv.definedone ();
call missing(arrival_dt_system, last_dt);
end;
merge
facs_sorted(in=from1)
f_lg_v(in=from2)
f_xclud(in=from3)
defaults(in=from4)
end = last_obs;
by ps_o_id ps_s_id ps_f_id period_dt;
rc = arv.find();
rc = nai.find();
drop rc;
if pd_e_flag EQ 'Y' then output f_xclud;
else output facilities;
run;
My understanding:
Its Creating a merged dataset from the 4 tables:
facs_sorted(in=from1)
f_lg_v(in=from2)
f_xclud(in=from3)
defaults(in=from4)
usinf the variables mentioned after "BY"
Then its left joining the merged table with the dataset mentioned under the two hash object with their respective keys.
Finally its storing the output table based on the variable pd_e_flag and its value,
Please let me know if I am missing anything. TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You are right. The two hash objects perform a lookup without the need for additional sorting of the base datasets (the result of the 4-way merge).