Sanderson Farms (SAFM) said on Tuesday that its second-quarter loss took a hit from higher raw material prices and weaker chicken prices, though its performance still swung ahead of Wall Street estimates, sending its shares higher in morning trade.

Higher feedstock costs led Sanderson to swing to a second-quarter loss from a year ago profit. Feed costs in flocks sold increased 41.3% compared with the second-quarter of 2010, and Sanderson said it expects grain prices to remain high and volatile for at least the rest of the year.

The Laurel, Miss.-based poultry processor posted a net loss of $16.3 million, or 74 cents a share, compared with a year-ago profit of $35.1 million, or $1.62 a share. Excluding one-time items, the company earned 56 cents, ahead of average analyst estimates polled by Thomson Reuters of an 85-cent loss.

Revenue for the three months ended April 30 was $479.3 million, down 1.6% from $487.1 million a year ago, beating the Street’s view of $473.2 million. The results fell despite slightly higher volume as a result of its new North Carolina facility, reflecting lower average sales prices of chicken.

“The results for our second quarter of fiscal 2011 reflect current market conditions and the overall economic environment,” Sanderson CEO Joe Sanderson Jr. said in a statement. “Demand from our food service customers has remained weak, and we expect this trend will continue with rising gas prices and high unemployment keeping consumers from dining away from home.”

Retail grocery store demand for chicken, though, remained strong and export demand continued to strengthen during the second period.

As the company looks forward, Sanderson said it will continue to closely monitor the chicken markets and productions levels as it heads into the summer months of what are typically a period of stronger chicken demand.

With the current economic conditions affecting consumer behavior, though, Sanderson said it anticipates continued weakness in food service demand.

Follow Jennifer Booton on Twitter at @Jbooton