This often depends on a number of factors.
The best way to make this decision is to compare what your rental costs will be versus your buying costs. If you are planning to remain in the property for 5 years or longer, buying will likely be your best bet.
If you are planning on moving in less than 5 years, the costs of purchasing, insurance, taxes and maintenance may be higher than renting for that same period.
If your income is W-2 income and you need tax deductions, then savings on taxes could offset some of the costs.
Loan costs will add about 3 to 5% to your cost to purchase.
As you can see, each buyer has a different financial and personal situation. So each buyer must examine rental costs versus buying costs in light of their future needs and plans.
Search online for rent versus buy calculators that can help you make easy comparisons of the costs.