As the year draws to a close, auto companies are again celebrating a near-record number of cars and trucks sold and a near-record average transaction price per vehicle.

But the news isn’t all good. New car sales for 2017 have been marked by demand for SUVs rising to unprecedented heights, while interest in traditional passenger cars has plummeted.

Many car companies that sell both kinds of vehicles have gained sales in one segment only to lose them in another. Manufacturers that lean more toward passenger cars could soon be stuck with factories and production lines making vehicles no one wants. If the trend continues, cars that once led sales segments could disappear altogether.

“This may mean that some successful car models are on the chopping block,” said Kelley Blue Book senior analyst Karl Brauer. “Basically everything in the large sedan category is an endangered species.”

Year-to-date sales in the U.S., compiled by the auto data company TrueCar, are running slightly behind the all-time high for 2016. Together, carmakers sold 14,175,611 cars and trucks through October, compared with 14,427,310 last year, when the full-year total ended at a record 17.5 million vehicles sold.

Cars are selling for more money too. The average transaction price for a new car in October was $35,263, according to Kelley Blue Book, $100 over October 2016 and slightly off the all-time high set last December.

The strongest segments by far were trucks and SUVs, which both outpaced passenger cars. The top-selling sedan is only the sixth top-selling vehicle this year.

Going into the last two sales months of the year, full-size truck sales were more than 100,000 units ahead of the same period last year. SUV sales were up more than 350,000 units over 2016.

But those losses are largely erased by drops in other categories — all of them passenger car groups.

All sedan categories were down.

The biggest negative growth numbers occurred in midsize, compact and subcompact cars. Together, TrueCar numbers show, car companies have sold half a million fewer cars in those three categories in 2017 than in 2016.

“A lot of the car companies are split,” said Jessica Caldwell, director of industry analysis for the auto research company Edmunds. “The truck and SUV business is doing decently, but they are struggling on the car side.”

That could mean a limited life expectancy for cars that a decade ago were solid sellers for major companies. Kelley Blue Book’s Brauer said he saw a doubtful future for the Hyundai Azera, Chrysler 300, Chevrolet Impala, Ford Taurus and Toyota Avalon.

“If my livelihood were depending on selling those cars, I’d be worried,” Brauer said.

The shift from sedans to SUVs is harder on companies that have focused more on passenger cars. Kia, Hyundai, Acura, Chrysler, Buick, Dodge, Chevrolet and Ford numbers all fell from 2016 to 2017, in part because their vehicle mix leans more heavily toward sedans.

Chevrolet and Ford have booming truck segments, as their non-truck vehicle sales fell by 70,000 and 100,000 units this year, respectively.

That has required some quick pivoting. Chevrolet was able to fast-track its affordable Trax crossover when it saw buyers leaning toward SUVs because it already was building the Trax overseas for foreign markets.

“Two or three years ago, the small SUV segment was almost nothing, but we saw a hole in our portfolio and were able to fill it quickly,” said Steve Majoros, the company’s marketing director for cars and crossovers.

As a result, Majoros said, car buyers are getting out of Cruzes and into a Trax or out of Malibus and into an Equinox or Tahoe.

“We’ll take a Malibu loss if the customer goes into a different Chevrolet,” Majoros said.

Toyota Camry and Corolla sales have declined, but sales are up the company’s Tacoma and RAV4. The RAV4 is the best-selling non-truck vehicle in the country.

Premium and specialty car companies are experiencing a similar scenario.

Sales for Jaguar, Maserati, Alfa Romeo, Porsche and Bentley are all up.

That’s largely because of the introduction of new SUVs, like Alfa’s Stelvio and Jaguar’s F-Pace, Caldwell said, and to ongoing strong sales of SUVs already in the market, like Porsche’s Macan and Cayenne.

Major American car brands are in a double bind. They are committed to building midsize and full-size sedans because those traditionally have made up most of their fleet sales to government agencies, for example, and rental car companies.

The shifting sales picture has created headaches at the retail level too. Many dealers have had to expand their space to accommodate new SUVs, while also saving room for the less-popular sedans — and keeping sufficient inventory of both types of vehicles, in enough trim lines and colors, to satisfy the manufacturer and customers.

“Dealers are being asked to build these huge Taj Mahal showrooms that showcase the SUVs and the whole lineup of cars, by manufacturers who believe they are following the market,” said Aaron Jacoby, who handles dealership legal matters for the Arent Fox.

The tension between the dealers and car companies is exacerbated, Jacoby said, because dealers are required every five to seven years to upgrade their showrooms to stay current with new models.

But the market is changing so fast that $5 million to $10 million face-lifts may not make sense if gas prices rise, for example, and SUVs and larger vehicles go out of favor.