''One of the hypotheses,'' said Mr. Groat, ''would be that affluent blacks have left San Francisco as the real estate market in the suburbs has opened up.'' Reasons for White Flight

Housing expenses, problems in the schools and a rising rate of violent crime in the city - the rate of reported rape in San Francisco in 1980 was nearly three times that of Chicago, and the robbery rate almost equal to Detroit - are all cited as contributors to white flight.

The data from the 1980 census have not been analyzed completely. But preliminary theories are that the major population loss has been among the middle class, particularly children.

''What is happening is that San Francisco is losing people, but it is gaining households,'' observed William Witte, deputy director for housing in the city's Office of Community Development. ''It's a net loss of people, a net gain in households, so there is more pressure on the housing market and more pressure on the people who can least afford it. The nationwide trend is to smaller households, and more households per capita, and that is exaggerated here, greater than the national trend. According to the latest figures, the size of the household decreased in the past decade from about 2.7 persons per household to 2.1, something like that. And the incomes went up.'' Exodus Linked to Housing Costs

A major reason for the exodus of the middle class from San Francisco, demographers say, is the high cost of housing, the highest in the mainland United States. Last month, the median cost of a dwelling in the San Francisco Standard Metropolitan Statistical Area was $129,000, according to the Federal Home Loan Bank Board in Washington, D.C. The comparable figure for New York, Newark and Jersey City was $90,400, and for Los Angeles, the second most expensive city, $118,400.

''This city dwarfs anything I've ever seen in terms of housing prices,'' said Mr. Witte. Among factors contributing to high housing cost, according to Mr. Witte and others, is its relative scarcity, since the number of housing units has not grown significantly in a decade; the influx of Asians, whose first priority is usually to buy a home; the high incidence of adults with good incomes and no children, particularly homosexuals who pool their incomes to buy homes, and the desirability of San Francisco as a place to live.

''What you have is a sharp drop in the birth rate, and what we've really lost is children under 15,'' said Dr. Rosen. ''We can't demonstrate it without the numbers, which we'll get in six months to a year, but it has happened in many cities. It's not people moving out of the cities. The number of households has gone up so the number of adults has gone up. People are not having kids, and there is the nontraditional life style. Traditional families are not being formed, people are not getting married and having children.'' More 'Nontraditional' People