he is marking territory, he won't do it if you don't let him. His hormones are driving him, or for neutered dogs it's dominance and habit. When nothing comes out it's because he ran out but the habit is still there. Make sure he's gone potty and then go for a walk for the first half of the walk no sniff and mark, if you have to stop have him sit, he can't mark if he's sitting, after that limit his marking. If you keep walking and tell him let's go and walk he doesn't have the time to stop sniff, get into position and then lift his leg, this takes time as you can see, walk, he can't stop and sniff and get into position when your walking can he? Use a negative word marker like UH Uh and say let's go. Good luck...