The random selection for screening happens (as far as I’m aware) at check-in, not when the ticket is issued. There is a code (as mentioned above, SSSS) that is assigned randomly at check-in: the TSA agents working the lines have no control over that.