* Fed could raise rates 'relatively soon' - Yellen
* S&P Financials rebound, helped by banks
* Consumer staples index hurt by Wal-Mart
* Consumer discretionary index boosted by data, Best Buy earnings
* Oct CPI rises 0.4 pct vs gain of 0.3 pct in Sept
* Indexes up: Dow 0.19 pct, S&P 500 0.47 pct, Nasdaq 0.74 pct (Updates to close, adds comments)
By Sinead Carew
NEW YORK, Nov 17 (Reuters) - The benchmark S&P 500 index rose to within a hair of its record high on Thursday as bank stocks got a boost from bets on higher interest rates and consumer discretionary stocks were helped by economic data and earnings.
Federal Reserve Chair Janet Yellen, in her congressional testimony, solidified bets that the central bank was on track to raise interest rates in December.
This signaled economic strength and helped consumer stocks as well as financials, said Janna Sampson, co-chief investment officer at OakBrook Investments LLC in Lisle, Illinois.
"I think it's strong earnings out of a few stocks, coupled with the economic data, that's buoying the market today," said Sampson, adding that some investors may be boosting their expectations for the holiday shopping season.
U.S. data for October showed consumer prices recorded their biggest lift in six months in October and housing starts surged to a more than nine-year high, helped by both single family and multifamily homes.
The housing data helped Home Depot shares rise 2.9 percent, making it the biggest driver for the consumer discretionary index and the second-biggest S&P boost.
Best Buy shares also helped with a 13.7 percent jump after the No. 1 U.S. electronics retailer's quarterly results beat expectations.
The S&P 500 gained 10.18 points, or 0.47 percent, to end at 2,187.12, compared with its Aug. 15 record of 2190.15.
The Dow Jones industrial average finished up 35.68 points, or 0.19 percent, at 18,903.82, and the Nasdaq Composite added 39.39 points, or 0.74 percent, to reach 5,333.97.
Six of the 11 major S&P 500 sectors were higher. The S&P Financial index was the leading advancer with a 1.3 percent gain, boosted by a 1.6 percent increase in the banking sub-sector
Yellen's vow to stay in her job for the rest of her term likely helped the broader market, said J.J. Feldman, portfolio manager at Los Angeles-based Miracle Mile Advisors.
U.S. stocks have been on a tear since Donald Trump's surprise victory in the U.S. presidential election last week, with the Dow closing at a record level four days in a row.
"We're still basking in the aftermath of the Trump election victory because of expectations for fiscal stimulus via lower corporate tax rates, but as time goes on investors will reposition based on what's actually happening," said Feldman.
Trump's promised increase in infrastructure spending is also expected to boost economic activity and inflation, and raises the possibility of more interest rate hikes.
Traders are pricing in an 83 percent chance of a December move, according to Thomson Reuters data.
The Dow's advance was held back by a 3.7 percent fall in Wal-Mart after the world's largest retailer reported lower-than-expected comparable quarterly sales.
Advancing issues outnumbered declining ones on the NYSE by a 1.11-to-1 ratio; on Nasdaq, a 1.60-to-1 ratio favored advancers.
The S&P 500 posted 35 new 52-week highs and 1 new low; the Nasdaq Composite recorded 262 new highs and 27 new lows.
About 7.4 billion shares changed hands on U.S. exchanges on Thursday, compared with the 7.9 billion average for the last 20 sessions.
Additional reporting by Tanya Agrawal and Anya George Tharakan; Editing by Bernadette Baum and Dan Grebler