stats "file1.dat" using 2 name "A" stats "file2.dat" using 2 name "B" if (A_mean < B_mean) {...}
Instead of providing a string constant as the name, the keyword columnheader or function columnheader(N) can be used to generate the name from whatever string is found in that column in the first row of the data file:
do for [COL=5:8] { stats 'datafile' using COL name columnheader }