Selection -> Sample Loop
Set the loop points based on the selection.
Create Loops in the Audio File Editor in Logic Pro — Apple Support
Selection → Sample Loop: The selected area is used to set the loop start and end points.
Create Loops in the Audio File Editor in Logic Pro — Apple Support
The Audio File Editor Loop commands, available from the Edit menu, are ideal for use with Sampler.
You can also use these functions to generate audio files that contain the loop settings in the file header. This allows you to make full use of these files in any app that can read the loop information in the file header.