Let x represent the amount loaned at 8%. Then the interest earned is given by
.. 0.08x +0.18*(20000-x) = 2000
.. -0.10x +3600 = 2000 . . . . . . . . . . collect terms
.. 1600 = 0.10x . . . . . . . . . . . . . . . . . add 0.10x -2000
.. 16000 = x . . . . . . . . . . . . . . . . . . . multiply by 10
$16,000 was loaned at 8%.