The nation's merchandise trade deficit last year was actually $10.2 billion less than the previously announced $166.3 billion, the Department of Commerce said yesterday as it unveiled a more accurate method of measuring trade figures.

Undersecretary of Commerce Robert Ortner said the department's counting of a large amount of previously undocumented exports to Canada, the United States' largest trading partner, accounted for the difference.

Ortner and Charles A. Waite, an associate director of the Census Bureau, which helps collect such government statistics, said that U.S. exports to Canada have been routinely understated. The reasons, they said, are inadequate record-keeping along the world's longest undefended land border and the exponential growth in U.S.-Canada trade.

"Say I'm driving a truckful of vegetable products in upstate New York and cross the border near Buffalo," Waite said. "I cross the border without filing the necessary export documents in the box the Customs Service provides at the crossing point. The goods never get reported as exports."

Last year, Ortner said, officials concluded that U.S. exports to Canada were underreported by about 22 percent. "When it gets that large, something has to be done," he said.

Canadian exports to the United States were underreported by only about 4 percent, apparently because Canadian customs officers patrol their border more carefully.

The reduction of the trade gap to $156.1 billion still left 1986 as a record deficit year for merchandise. However, the adjustment could help the administration in its efforts to soften support for protectionist legislation in Congress that would combat the deficit with sanctions against nations that run large trade surpluses with the United States.

The $10.2 billion increase in reported exports to Canada dropped the bilateral U.S. trade deficit with that nation to $13.3 billion. That revision is unusually large, Ortner said, and Census Bureau sources said that the adjustment for this year could be as much as $6 billion.

The new formula will be reflected in revised trade deficit estimates for the first half of 1987 that are to be published Friday