Depends upon the relationship between purchase price and rental price, for the same piece of real estate. Around here, rental prices are so high that you're often better-off buying, mid-term. You're only out the down payment and closing costs, and that is often back in saved rent (including the inevitable increases), within 10 years.
I wouldn't buy real estate as an investment, tho.