Hi There, I recently came across the HASH object which made my like much easier. Following is the program using HASH object to match 1:10 cases with controls. We can not use PSMatch, it is completely different than the match we do directly by comparing variables. data controls; set controls; matchkey = catx('_', gender_control , age_control); proc sort data = controls out=controls; by matchkey; run; data cases; set cases; matchkey = catx('_', gender_case , age_case); proc sort data = cases out=cases; by matchkey; run; data matched_ctrls(keep=id_case gender_case age_case id_control gender_control age_control ); Length id_control $20 age_control 8 gender_control $2 matchkey $20; if _N_ = 1 then do; declare hash controls(dataset:"controls", multidata: "Y"); controls.defineKey("matchkey"); controls.defineData("id_control","age_control","gender_control", "matchkey"); controls.defineDone(); declare hash used_controls(); used_controls.defineKey("id_control"); used_controls.defineDone(); end; do until (last.matchkey); set cases; by matchkey; match_count = 0; rc = controls.find(key:matchkey); do while(rc = 0 and match_count < 3 ); if used_controls.check(key:id_control) ne 0 then do; output; match_count+1; used_controls.add(); end; rc = controls.find_next(); end; end; run;
... View more