A Senate subcommittee yesterday added $30 million to the District's budget to build a prison in the District to relieve crowding in the city's corrections system.

Sen. Arlen Specter (R-Pa.), the prime mover behind the project and chairman of the panel, said he hopes that a 1,000-bed prison will open in the District within two years. The federal funds to design and build the hotly debated prison project were added to the District's fiscal 1986 appropriations bill and are expected to be approved by the Senate and House without difficulty.

Mayor Marion Barry, who this year endorsed a new prison after opposing one for some time, stressed yesterday that his support is contingent on the federal government paying for construction and providing the site. A prison study commission appointed last week by the mayor and the City Council is to submit recommendations on the size, type and location of the proposed facility in January.

"Meanwhile, we have the money in the bank," Barry said.

After the meeting of the Senate Appropriations subcommittee on the District, Specter said that he has been concerned for the past 2 1/2 years about serious problems in the D.C. prison system. Without additional prison space, he said, "There is a risk that judges won't be sentencing violent criminals to jail because of the prison overcrowding situation."

Specter said the subcommittee has projected a need for a 1,000-bed facility and said he hoped the mayor's study commission could make preliminary recommendations on a site and size by the end of August, although he noted that this might not be possible.

Specter had pushed Barry to agree to the new prison, which the senator has argued is needed to deal with an expected rise in convictions and sentenced felons as a result of increasing drug arrests and new mandatory minimum sentences for certain types of crimes. Facing this pressure and court orders to relieve crowded conditions, Barry reversed himself at hearings this year.

The subcommittee specified that $10 million of the prison funds would be available in fiscal 1986, which begins Oct. 1, and $20 million in fiscal 1987. It also added these federal funds to the city's $2.3 billion 1986 budget:

*$6.7 million to continue an educational program at the District's Lorton Reformatory in Fairfax County, an initiative that Specter added to the city's appropriations legislation two years ago to train inmates to help them get jobs.

*$500,000 more for job training. Matthew Shannon, D.C. Director of Employment Services, said the funds would be used to expand the city's current $2 million out-of-school job program, which provides on-the-job training for young people.

*$500,000 to expand school truancy programs begun this year.

D.C. School Superintendent Floretta D. McKenzie said the school truancy money would enable the city to establish two or three student attendance centers in addition to an experimental one started in March with federal funding. The center provided counseling services for 360 chronically truant students in the last three months of the school year, she said.

McKenzie, announcing that the systemwide school attendance rate exceeded 90 percent this year for the first time, said the student attendance center and other federally funded initiatives "contributed measurably" to the improvement.

Specter pointed to police statistics showing that larcenies and burglaries during school hours dropped significantly during the three months that the attendance center served the targeted area, the police department's 1st District in Northeast.

The subcommittee added language to the city's budget bill encouraging the District to raise its drinking age for beer and wine to 21, as Maryland and Virginia have done.

Proposed by Sen. Frank R. Lautenberg (D-N.J.), the subcommittee's new ranking minority member, the measure puts congressional panels in the House and Senate on record as concerned about the city's refusal to raise the legal age from 18.

Barry has not taken a position on the issue, and the D.C. City Council has not acted on legislation introduced this year to raise the drinking age.

Rep. Julian C. Dixon (D-Calif.), chairman of the House Appropriations subcommittee on the District, has said he would support federal funding of a prison in the District, although his panel did not add the funds when it approved the city's budget bill last week.

Sen. John W. Warner (R-Va.), who along with other members of Virginia's congressional delegation has been trying to get the District to build new facilities in the city to relieve pressure at Lorton, called the subcommittee's action "a milestone" and called for the city to begin construction within the next year.