The government yesterday reported sharp increases last month in both retail sales and factory production, combined with the biggest drop in wholesale prices in more than two years.

Private and government economists said yesterday's reports along with other recent statistics suggest the worst of the yearlong economic slump may be over.

President Reagan, in a statement released by the White House, called the latest economic statistics "very encouraging" and said they provided "further evidence of the miraculous powers of American enterprise."

Beryl Sprinkel, chairman of the president's Council of Economic Advisers, said the figures reaffirmed the administration's expectation of a 5 percent growth rate in the last half of this year.

Commerce Secretary Malcolm Baldrige, in contrast to the optimism of Reagan and Sprinkel, said that although measures of consumer confidence remain high, consumer spending should continue to increase "but at a lesser rate than in the first half, particularly if consumers raise their rate of saving from the low current levels."

In separate reports yesterday:

*The Commerce Department reported that retail sales rose 1.9 percent in August, the largest gain since April. Retail sales rose 0.2 percent in July. A large part of the increase was in car sales, which rose 7.8 percent, pushed by discount dealer financing for new cars. Excluding automotive group sales, retail sales were little changed from July. Sales at general merchandise stores rose 2.9 percent, purchases from gasoline service stations rose 1.7 percent, and drugstore sales increased 1.6 percent. Food store sales declined 0.8 percent in August, and apparel sales rose 1 percent.

*The Federal Reserve Board reported that industrial production at the nation's factories, utilities and mines increased 0.3 percent in August. The manufacturing sector, which has been battered all year by imports, jumped a sharp 0.5 percent after no change in July. Production of durables increased 0.7 percent while nondurables increased 0.2 percent. Production at mines declined 0.6 percent following a 0.7 percent decline in July, and at utilities production dropped 0.3 percent in August following a 0.4 percent decline in July.

*The Labor Department reported that the producer price index declined 0.3 percent in August, the biggest drop in 2 1/2 years. Producer prices increased 0.3 percent in July. The report showed that costs of consumer foods dropped 0.7 percent following a 1.3 percent increase in July. Goods at the intermediate level of processing dropped 0.2 percent following a 0.3 percent decline in July, and crude goods prices dropped 2.4 percent after falling 0.6 percent in July.

Private economists said the statistics released yesterday, along with other recent reports, suggest that the economic slump may have bottomed out. Other statistics cited include the drop in the unemployment rate from 7.3 percent to 7.0 percent last month, the improvement in home sales, an increase in new orders for factory goods, a rise in the government's main gauge of economic activity and the surge of new-car buying.

However, the economists also cautioned that the economy will continue to be battered by imports and that it still is not clear how strong consumer spending will be outside of automobile sales.

Several private economists said that while the pickup in economic growth will be stronger than they expected, it still will not meet the expectations of the Reagan administration. Rather than 5 percent growth in the second half, these economists predicted output would increase from a 1.1 percent rate in the first half to about a 3 percent pace in the third quarter and slightly more in the last three months of the year. They also cautioned that too much should not be read into one month of data.

In the first half of the year consumer spending was strong, although a large part of it went to imports. Many economists have said they expect consumer spending to slow somewhat because households are carrying historically high debt loads and have run down savings to finance purchases in the beginning of the recovery.

"Together, the data give the best performance of the economy in many months," said Allen Sinai, chief economist for Shearson lehman Brothers. Sinai said that the industrial production figures "are hinting that the worst is over for U.S. manufacturing. However, it does not indicate that we're off and running and the industrial sector is on the road to recovery. The deterioration may have ended. There is a likely bottoming out process going on in what has been a recession" for the nation's manufacturers.

"Clearly, consumers are spending again," said David Jones of Aubrey G. Lanston securities dealers. The increased economic activity will largely benefit growth in the fourth quarter, which begins in October, Jones said. The positive spending attitude reflected in strong car sales in August and so far in September "may spill over into other consumer goods as well," Jones said.

Jones said that until recently he forecast economic growth in the fourth quarter at less than 3 percent. Now he said it could be 4 percent or better.

One psychological factor affecting consumers may be bargain hunting, which has been a major spur for growth in automobile sales as auto companies have slashed financing rates from as high as about 12 percent to as low as 7.5 percent. "Consumers are in a better condition to spend now if there's a bargain," Jones said.

Jerry Jasinowski, chief economist for the National Association of Manufacturers, said that the statistics "don't yet provide clear evidence of a significant economic rebound. The surge in retail sales was largely due to automobile sales, and the decline in producer prices suggests that there is slack demand for goods in the economy."