If you look at Berkshire Hathaway's portfolio, it's easy to see a common trend among the largest holdings, which include Coca-Cola and Apple. They are resilient businesses that have wide moats, which is a defendable competitive advantage.

Owner and billionaire investor Warren Buffett values companies with moats, and it's often due to a company's strong underlying brands. There's one thing that he says is the most important when it comes to evaluating a business: Pricing power. That all comes back to having a strong brand, because without that, a company wouldn't have much pricing power at all.

A couple of stocks that have been doing well over the past year, demonstrating their pricing power, are Kraft Heinz (KHC -0.52%) and PepsiCo (PEP -0.41%). Here's why these are two investments you should consider buying and holding for the long haul.

Kraft Heinz

Pricing power is the first thing I think of when it comes to Kraft Heinz. For instance, you could save a couple of dollars by downgrading to a no-name brand of ketchup, but for something that people consume quite regularly and that can last for weeks, there may not be a big enough incentive to do so, especially if there's a discernible difference in quality.

Based on Kraft's quarterly results, I'm inclined to believe that many people agree with that sentiment. Although Kraft has raised its prices, its net sales of $26.5 billion last year were up 1.7%, and that would have been even better if not for foreign exchange. The company's organic growth, which excludes the effect of foreign currency and acquisitions and divestitures, was 9.8%. Although price increases were behind the sales growth, overall volumes were down just 3.4%.

If the company's products were easily replaced with no-name store brands, I would have expected to see a much larger decline in volume. The absence of that leads me to believe that people aren't overly eager to dump Kraft's brand name products for the store brands.

Kraft, however, isn't pushing its limits. In February, it said it would stop raising prices, recognizing that there could be more resistance to ongoing price hikes. But that the company has been able to do so well amid inflation remains a positive sign for investors that the brands are strong, and it's little wonder why this remains one of Buffett's top stocks.

It also pays an attractive dividend yield of 4.1% that is more than double the S&P 500 average of 1.7%.In the past 12 months, Kraft's stock has been relatively stable, losing just over 2% in value.

PepsiCo

Another blue chip stock in a similar position to Kraft is PepsiCo. Its soft drinks and snacks aren't terribly expensive, and that plays into its favor. Moving down to a no-name product may save you only a few dollars or less, in exchange for a worse-tasting product.

Similarly, PepsiCo has posted some strong results of its own, with net revenue of $86.4 billion in 2022 rising by 8.7%. Organic revenue growth was far higher at 14.4%. In North America, its beverage business saw no significant declines in volume last year despite price increases, and its Frito-Lay business saw just a 1% drop in volume.

The only international market where there was a decline in volume last year was in Europe, which was down 7% in beverages and 4% for food products. But when factoring in price increases, the overall organic growth rate there was still a healthy 12%.

PepsiCo's business remains in solid shape and it has made a good investment over the past year, with the stock rising 8% while the S&P 500 has declined more than 9%. PepsiCo also pays an above-average dividend yield of 2.5% and can be an excellent investment to buy and hold.