D.C. Mayor Marion Barry underwent drug testing yesterday for the first time since he was arrested on cocaine possession charges at the Vista Hotel in January, as he arrived for his first appointment with federal probation officials.

Barry showed up at the federal courthouse at Third Street and Constitution Avenue NW shortly before 10 a.m. for a meeting with his probation officer, Deputy Chief Probation Officer Arthur Carrington, as he was instructed to do on Monday by U.S. District Judge Thomas Penfield Jackson. The meeting, which is routine for drug defendants, stems from Barry's conviction on Aug. 10 on one misdemeanor count of cocaine possession. Jackson has set sentencing for Oct. 26.

Sources familiar with the case confirmed that Barry was required to undergo urinalysis to test for drugs, which also is a routine requirement for drug defendants. But it was not known when the results of the test would be sent back to the probation office. Normally, drug test results and other pre-sentencing information compiled by the probation department are confidential.

Barry, looking somber, did not emerge from his meeting until nearly four hours later. Asked why the meeting had taken so long, he said, "It's a long story."

Jackson had asked for the pre-sentence report at a hearing Monday in the case. Prosecutors announced then that they would not seek retrial on the 12 cocaine possession and perjury counts on which the jury deadlocked.

Probation officials could not be reached for comment yesterday about the Barry case. But federal sentencing guidelines require the pre-sentencing report to be an exhaustive description of the defendant, his family background, criminal history if any, education and physical condition.

Using a federal sentencing guideline manual, which provides formulas for calculating prison time for federal offenses, the probation officer comes up with a sentencing recommendation for the judge. That recommendation is based on such factors as the nature of the offense, the defendant's role in it, whether there were any aggravating or mitigating factors and whether the defendant tried to cover up his crime.

Jackson is not bound to follow the probation office's report. But if he departs from what the sentencing guidelines recommend, he will have to justify his decision in a written order, which Barry can appeal.

Meanwhile, several Barry associates said the mayor is firmly committed to a campaign for an at-large D.C. Council seat, despite private worries by some friends about such a bid.

Barry campaign manager Anita Bonds could not be reached for comment, but Barry friend Jeffrey N. Gildenhorn said Bonds told him yesterday that the mayor hopes to raise $150,000 to $200,000 by the Nov. 6 election. "She emphasized the point that the campaign is on," he said.

Ward 2 council member John A. Wilson, who will become chairman in January, added his voice to the growing chorus of politicians, including Republican mayoral candidate Maurice T. Turner Jr., who say Barry should not run. "The mayor ought to retire for a few years," Wilson said in an interview. "The city needs a fresh start . . . . The mayor is going to have to defend the policies of the past, and those policies are failed at this point."

Staff writer Michael Abramowitz contributed to this report.