The Environmental Protection Agency announced yesterday that the Union Carbide Corp. would be fined $3.9 million for illegally withholding for more than four years information that one of its products produced skin cancers in laboratory animals.

The chemical, diethyl sulfate, is an intermediate chemical in the production of dyes and textile finishes. The EPA already knew that the substance could cause birth defects.

But the agency said yesterday that Union Carbide knew as early as 1979 that the chemical was a carcinogen, as well, and that it did not share that information with the government until 1983.

EPA Assistant Administrator John A. Moore said that Union Carbide's action was a "clear violation" of federal law, which requires chemical companies to report any "significant health effects" associated with their products.

"The Union Carbide study produced new information . . . that could have influenced regulatory decisions at EPA and other federal agencies," Moore said.

In a statement from its headquarters in Danbury, Conn., Union Carbide said it "can see no basis" for the fine, which amounts to $25,000 for every day that the company kept the information to itself.

"That information was not reportable . . . because it simply confirmed that diethyl sulfate was a suspect carcinogen," the statement said.

The company is allowed to appeal the fine. The EPA has fined two other chemical companies for similar infractions of the law, but they paid fines of $50,000 or less.

According to the EPA, diethyl sulfate poses almost no hazard to the general public and "minimal" hazard to workers, because of manufacturing methods.