The failure of the United States to close its huge trade gap cost the country as many as 5.1 million jobs during last year alone, the Economic Policy Institute reports.

In a study titled "Trading Away Jobs," the non-profit organization concluded the $170.3 billion deficit in 1987 meant the millions of employment positions were lost to foreign competition, 60 percent of them in manufacturing and the other 40 percent to related industries.Moreover, compared with the rest of the economy, the lost jobs tended to pay higher wages; there were 2.5 million fewer positions worth more than $400 per week because of the trade deficit, according to the study issued Sunday.

The government last week reported the deficit for 1988 was running toward $138.5 billion. Republican Vice President George Bush has attempted to focus on the improvement while his Democratic White House rival, Massachusetts Gov. Michael Dukakis, has emphasized the record highs under the current administration.

The liberal policy institute conducted its non-partisan study for New York University's Institute for Economic Analysis, reporting that all regions of the nation were hurt by the loss of jobs because of increased imports.

Imports took their biggest toll on heavy industry in the Northeast and Midwest, machinery and metal manufacturing; light industry in the South, textiles and furniture; and business services in the West, the study found.

Jeff Faux, head of the policy institute, said, "These calculations make it clear that jobs in every region of America are being destroyed and potential jobs are not being created because of our failure to close the trade deficit."

Nearly 700,000 professional jobs would be created if the country balanced its trade figures, the study asserted in what it termed a surprising finding.

Unlike previous surveys that assumed a nation completely closed to trade to measure potential job loss, the institute based its figures on an assumption of higher exports and lower imports.

Eliminating the trade deficit would create 2.7 million jobs because of higher exports and another 2.4 million because of lower imports, with all regions regaining more jobs by expanding foreign markets than by limiting imports.

In the Northeast and Midwest, a balance of trade would benefit machinery and metal manufacturing most in terms of employment, the study found. The South and the West would realize the greatest rise in jobs in business services.