Warren Buffett has created tremendous wealth for Berkshire Hathaway shareholders, and his career has inspired many investors to follow his every move in the stock market. As of the third quarter, the company held a stock portfolio worth $271 billion. Here are two stocks Berkshire has held for several years that are excellent buys right now.

1. Coca-Cola

Coca-Cola (KO -0.46%) has been a staple in Berkshire Hathaway's stock portfolio for decades. Buffett originally bought shares for the company in the 1980s, and while it's not a fast-growing business today, it's a strong brand that can deliver returns on par with the market averages while also paying a generous dividend yield.

This is a simple business with a powerful business model that churns out healthy margins and free cash flow. The company generates a lot of its revenue from selling concentrate to bottlers that make the finished product. It's a relatively capital-light business that allows Coke to earn a high profit margin of 22%.

It's been a challenging consumer spending environment for many brands, but Coca-Cola remained resilient. While sales volumes fell slightly in Q3, adjusted revenue grew 9% year over year from higher pricing. Morgan Stanley recently reiterated an overweight (buy) rating on the shares, as the firm sees potential for Coca-Cola's adjusted revenue to grow faster than competitors' as inflation headwinds ease in the economy.

Beyond its namesake brand, Coca-Cola ultimately benefits from owning a large portfolio of beverage brands that can deliver sales depending on the shift in consumer preferences. The company is also using artificial intelligence (AI) to improve marketing, which management expects to drive increases in retail sales.

The stock currently offers an attractive dividend yield of 3.13% at the time of this writing, based on a quarterly payout of $0.485 per share. The high yield combined with opportunities to gain market share in a growing $235 billion beverage industry, according to Statista, makes Coke stock a no-brainer buy right now.

2. Amazon

Berkshire Hathaway has held a position in Amazon (AMZN -0.56%) for more than five years. It continued to hold 10 million shares in Q3. Amazon shares have created enormous wealth for investors over the last 20 years, but the company still has tremendous opportunities ahead in e-commerce and cloud computing to continue rewarding shareholders.

Amazon stock surged to new highs after its third-quarter earnings report, which showed a solid 11% year-over-year increase total revenue, but importantly, a significant increase in profits from management's cost savings initiatives.

Amazon posted an impressive 55% year-over-year increase in net income in Q3, but the company is still pursuing opportunities to boost profitability in the retail business. It recently opened a new fulfillment center in Shreveport, Louisiana, that uses advanced robotics to help with picking, packing, and shipping orders. This new facility can reduce processing time by 25%, and therefore, reduce costs.

Meanwhile, Amazon's cloud computing business is looking very strong. Revenue growth accelerated again to 19% year over year, as more businesses continue to migrate their data from on-premise servers to the cloud. Because Amazon Web Services generates about 60% of the company's operating income, more growth in this business is also a major catalyst for Amazon's improving profitability.

Amazon truly looks like an unstoppable business. It generated $49 billion in trailing-12-month net income. It is delivering profitable growth while investing in AI technology to drive demand in cloud services and also enhance the shopping experience in the online store.

The stock still trades well within its historical valuation range, whether looking at price-to-sales, price-to-earnings, or price-to-free-cash-flow ratios. Investors should see excellent returns that reflect the underlying growth in the business over the long term.