Last November, fellow Fool Morgan Housel pointed out that as of 2009 the banking industry, in aggregate, had not turned a profit over the previous 100 years.

That is about as bad of a track record as you'll ever see, and it comes despite the fact that if you really break it down, banking is a simple business.

Banks collect deposits and extend loans, and profit from the interest rate difference in between. Keep costs in line and throw in some fee income from a few value-added services, and you've got yourself a high performing bank. It sounds easy enough, right?

Why, then, is it so difficult for the banking industry to sustain its profits whenever the economy taps the brakes? And, more important for investors, how can you find bank stocks that will sustain those profits over the long term, even when the industry at large doesn't?

The answer is so obvious it hurts
Before the big reveal, let's quickly set the table with a few important facts about banks.

First, banks are highly leveraged. A typical bank has $1 of equity for every $10 of assets. That means that if an average bank's assets lose just 10% of their value, then 100% of that bank's equity is wiped out.

Second, banks are in the business of making loans. That means when a bank sells a product (a loan), then it must get it back. If a bank fails to collect a loan, then it not only loses its revenue (in the form of interest) but also its equity (in the form of the principal).

This reality creates a tension within the culture of every bank. On the one hand, the sales team wants to make as many loans as possible, because sales are good. But on the other hand, the risk management team only wants to make loans that will be repaid. The optimal balance is somewhere in between; banks need loans for revenue, but those loans must be repaid for the bank to survive.

So what is the single most important thing to consider when buying a bank stock? Credit quality: a bank's ability to minimize loan losses throughout the economic cycle.

Some data to back this up
There are literally hundreds of metrics investors can use to analyze a bank. There's the efficiency ratio, return on equity, return on assets, the Texas ratio, and so many more.

Warren Buffett uses return on assets as his primary metric, so we'll piggyback on the Oracle of Omaha's wisdom (there is also some evidence that a bank's market valuation is correlated to that return on assets number).

Using data going back to 1984 from the FDIC's Quarterly Banking Profile, we can calculate the correlation between a variety of metrics and return on assets for the industry. The hypothesis is that the banking industry's return on assets will correlate highly with metrics measuring asset quality over simple profitability or growth.

ROA Correlation With:Correlation (r-squared)
Efficiency ratio 38%
Quarterly net charge-offs (as a % of loans and leases) 35%
Quarterly loss provision (as a % of net operating revenue) 81%
Loans 30-89 days past due (as a % of total loans) 62%
Total noncurrent loans (as a % of total loans) 44%
Net interest margin 22%
Percent of institutions with year-over-year earnings growth 28%

Based on this data, the primary factor driving a bank's return on assets is its loan loss provision. The loan loss provision is the money that banks put aside every quarter based on management's estimates of future loan losses. In other words, it's a required contribution to the bank's rainy day fund.

The more borrowers that fall behind on their payments, the higher the loan loss provision and the worse the bank's return on assets. It makes sense that loans 30-89 days past due would be the second-highest correlation. These loans are in trouble and getting worse, but they are not yet in such bad shape as to create a loss.

Two banks with a track record of success
For bank investors, the next step is to apply these conclusions to specific stocks. To me, the best two banks to start your search are the same two banks at the top of Buffett's list: Wells Fargo (WFC 5.61%) and U.S. Bancorp (USB 2.94%).

These banks  respectively had ROA of 1.5% and 1.6% as of the second quarter, crushing the industry average of 1.08% for banks with total assets greater than $10 billion. Both banks managed through the financial crisis without the crushing loan losses that wiped out years of accumulated profits at other banks, and their shareholders have been justly rewarded since then.

USB Chart

USB data by YCharts.

Investing in the banking sector can be lucrative, as long as you invest in banks that don't give back years of profits every time the economy takes a dip. The key to doing that is finding banks that make good, high-quality loans.

It's a painfully obvious truth, yet very few banks successfully do it.