Hi there, I recently started learning hash objects, while I'm surfing net, I found we can also use set statement to pass the data and key values into hash objects. I have been trying to use this approach as shown below. What i'm looking is, i want to use set statement instead of using dataset tag. And would like to get merge both datasets (forget about the duplicates in hash object keys and values). Raw datasets: data participants; input name $ gender:$1. treatment $; datalines; John M Placebo Ronald M Drug-A Barbara F Drug-B Alice F Drug-A ; data weight(drop=i); input date:DATE9. @; do i = 1 to 4; input name $ weight @; output; end; /* For brevity, only two dates are listed below */ datalines; 05May2006 Barbara 125 Alice 130 Ronald 170 John 160 04Jun2006 Barbara 122 Alice 133 Ronald 168 John 155 ; Tried Code: data results ; if _n_=1 then do ; declare hash h( ) ; h.definekey('name') ; h.definedata('name','weight') ; h.definedone() ; end; set weight end=eof ; if h.find() ne 0 then h.add() ; set participants ; if h.find()=0 then output ; h.output(dataset: 'a'); run; Using this, am getting only two records, as shown in the trial image. Im getting correct results using dataset tag argument: Code: data results1 ; length weight 8; /*attrib weight length=8;*/ /*retain weight . ;*/ if _n_=1 then do ; declare hash h(dataset: 'weight') ; h.definekey('name') ; h.definedata('weight') ; h.definedone() ; call missing(weight) ; end; set participants ; if h.find()=0 then output ; run; PLEASE HELP ME IN UNDERSTANDING BOTH Thanks in advance
... View more