A picture would have been nice.
The state after the first SG device is:
$$ \psi_1 = \delta(x)\delta(z-z_0)|\uparrow\rangle $$
meaning it spin up in the $z$ direction and forms an (idealized) beam moving in the $y$ direction (ignoring $y$ dependence--you can make it a plane wave or a single atom in a plane wave or a wave packet. It's at $x=0$ and $z=z_0$.)
Now you pass the $SG_x$. It does not measure the spin, rather it entangles it with position:
$$ \psi_2 = \frac 1 {\sqrt 2}\Big(
\delta(x-x_0)\delta(z-z_0)|\leftarrow\rangle
+
\delta(x+x_0)\delta(z-z_0)
|\rightarrow\rangle\Big)$$
This means half the amplitude is spin left (right) in the left (right) beam.
If you now place a screen, half the atoms will hit the left spot and half the atoms will hit the right spot.
If you have one atom, its impact is 50/50. A coin-toss, as they say.
If it hits the left (right) spot, I think it was in the left (right) beam. If on the other hand, you have an inverse $SG_x$ device--and this is the quantum magic of the Stern-Gerlach experiment-- an measure its spin-up state, it will recombine the beam/atom into:
$$ \psi_3 = \psi_1 $$
which means your single atom was in both the upper and lower beams (a la Young's Double Slit experiment with electrons).
The basic quantum rule, which is a discreet version of Feynman's Path Integral formulation, is that to get from an initial state to a final state (with no detecting/decoherence in between), you take all allowed paths, and add the amplitudes...and then square for a probability.
This is much safer than trying to intuit what a single atom is doing--because if you detect it in the upper beam, it was always in the upper beam, and if you recombine the beams so both paths are possible, it took both paths.
(Note that this implies some kind of delay choice--how did the atom know it was going to be detected so it had to be in the upper beam? To paraphrase Marsalas Wallace, "That's classical thinking messing with your find. ^*&#@ Classical Thinking". Rather, just invoke the coherence length/time of the beam, and if the detection was outside the coherence length/time between the detector and the split beam: the state decoheres and there is no quantum woo, and if it was inside that window: then it was at both places at once so of course it "knew" what to do).
Finally, due to simplicity of your set-up (a pure state going into the 2nd device) I was able to use spin/position eigenstates.
For a more general SG problem (say, if you had not blocked the spin down beam and sent it to something else)...then you really need to use density matrices, esp. when you start of an unpolarized beam, since it is a mixed state and can only be described by $\rho$.