Hello Based upon your first two datasets results and reference the outcome does not appear to be what you have shown. However using the sample code you should be able to get the desired result as shown
data results;
input ID resultA resultB;
datalines;
1 2392 887
2 1587 902
3 2392 234
4 4035 2392
;
run;
data reference;
input num first$ last$;
datalines;
2392 joe bloggs
4035 mary smith
1587 bloggs joe
234 sherlock holmes
902 john watson
887 benjamin button
;
run;
proc sql;
Select id, cat(Propcase(strip(first)),"-",propcase(Strip(last))) as Name from results a,reference b
where a.resultA=b.num;
quit;
The code gives result like this with the given datasets results and reference.
... View more