This works on my laptop where the second group has 200,000 observations with 7 variables. I run the first group by dividing into blocks of 20 observations - read next &BlockSize var MvarNames into S; /* 4. Read block */. Question: how to I get the value of an ID variable for the second group rather than just the observation number - idx[,j] = D[ ,>:<]; /* column of smallest distance in each row */ Thank you.