First of all, writing dp/dy=p' implies that you're differentiating
with respect to y. Otherwise, you are right, dp/dy is not equal to dp/dx in this case.
The expression \frac{dp}{dy} is really just a short-hand for the chain rule. The best thing to do here is not to think of p as a variable but instead as a function p(y(x))=y'(x). What it's asking is "What happens to the value of p(y(x)) as the value of y(x) changes?" That is, we want to find
\frac{{\rm change\ in\ }p\bigl(y(x)\bigr)}{{\rm change\ in\ }y(x)},
or, in "semi-short-hand" notation,
\frac{dp\bigl(y(x)\bigr)}{dy(x)},
and in standard short-hand notation,
\frac{dp}{dy}.
Now, since both p(y(x)) and y(x) are in terms of x, we can re-write these (albeit with a slight abuse of notation) as
<br />
\begin{align*}<br />
\frac{dp}{dy} &=\frac{dp\bigl(y(x)\bigr)}{dy(x)} \\<br />
&= \frac{dp\bigl(y(x)\bigr)}{dy(x)} \cdot \frac{dx}{dx} \\<br />
&= \frac{dp\bigl(y(x)\bigr)}{dx} \biggl/ \frac{dy(x)}{dx}\\<br />
&= \frac{dp}{dx}\biggl/\frac{dy}{dx}\\<br />
&= \frac{y''(x)}{y'(x)}.<br />
\end{align*}<br />