The problem of the lateral containment of a 160 MeV proton beam interacting with a medium simulating biological material was studied. The confining action of a longitudinal magnetic field was calculated by means of Monte Carlo simulation, where scattering and motion in the magnetic field were treated simultaneously. Appreciable compression of the beam could only be achieved using fields of the order at least 50 T, much beyond the realm of practical feasibility.