I`m reading Melvin B. Nathanson's "Elementary Methods in Number Theory" and I can't think of a way of deducing Selberg's formula (9.3) from the prime number theorem. This is one of the tasks left for the reader at the end of chapter 9.3 (The Elementary Proof).
$$(9.3) \qquad \qquad \vartheta(x) \log x + \sum_{p \leq x}(\log p) \vartheta(x/p) = 2x\log x +O(x)$$
Simply replacing $\vartheta(x)$ by $x + o(x)$ results in error terms of order $o(x\log x)$ which are strictly worse than error terms of order $O(x)$.
I feel like I'm missing something rather simple, but I've been wasting just a little too much time on that exercise. Thanks in advance!