Dear SAS Forum,
I'm just starting out with the hash object. I was under the impression that if the find method cannot find a match then "nothing" is returned in the datavalues. However it looks like the last value in the PDV is returned if the find method cannot match to the key.
I thought that I could mimic a left join with the hash object. I could use call missing on grade before the find method?
Can someone shed some light?
Thanks
data grades;
input gname $ grade $;
datalines;
Alfred A
Alice B
Barbara A
Carol D
Henry C
James B
Jane B
Janet C
Jeffrey A
John A
Joyce D
Judy F
Louise A
Mary A
Philip C
Robert C
Ronald C
;
run;
proc sql;
create table class1 as
select a.*, b.grade
from SASHELP.CLASS a left join grades b on a.name=b.gname
order by a.name;
quit;
data class2;
if 0 then set grades(obs=1);
if _n_ eq 1 then do;
declare hash grades(dataset:"grades");
grades.definekey("gname");
grades.definedata("grade");
grades.definedone();
end;
set sashelp.class;
rc=grades.find(key: name);
run;
proc compare data=class1 compare=class2;
run;