In a song, the actual number of bars can vary quite a bit. Usually, the length of the song determines the bar length, but there are exceptions with drum samples, especially in songs with a warped timeline grid. If you’re making loops, it doesn’t really have to be that complicated.
When composing an average loop, four bars is a good, solid number to start with musically. Often enough, this number can give your listener a good idea of the outline of the song and the way things will end up sounding eventually. Going any more isn’t really worthwhile, while a few bars less (let’s say, two) will not be a good enough sample to base any opinion on. Four bars is usually enough to also add some variance in the drum samples towards the end. While velocity modification is a great technique to make use of, also introducing instruments towards the end can be a great way to spice things up in your beat. You want to keep the listener comfortable and on the edge of his or her seat at the same time.

