Consider PROC SQL with a sub-query (to get the minimum) or a DATA step using a MERGE / BY statement technique, while using a PROC SUMMARY to get the minimum value for your BY group.
> Something like this???
>
>
> data one/view=one;
> set hello;
> length diff 8;
> diff = var1 - var2;
> un;
>
> proc sort data = one out = two;
> by id diff;
> un;
>
> data three;
> set two;
> by id diff;
> if first.id then output;
> un;
good approach and allowing ID groups.
May need refinement to ensure dif is only positive.
The first refinement[pre]> diff = abs( var1 - var2) ;[/pre]