Is there a way to use sandr (or other cmd) to change the first occurrence of a pattern to "x" and the second occurrence of the same pattern to "y" and so on.
Yes, although the best way may depend on what you want the x and y to be. A '+' in the replacement string will put an incrementing number, if you want x to be 1, y to be 2 etc.
The other option would be to use <fmtcp sandcall> which allows a Vortex function to be called each time the pattern is matched. It can use a variable to keep track of how many times it has been called, and behave appropriately. You can use <capture> around that if you need the results in a variable rather than output to the screen.