CEOs of mostly midsize companies are largely optimistic about the business environment, but have grown more pessimistic for the third straight quarter, according to a new survey.

Of the 278 CEOs surveyed, 96.06 percent rated their businesses' outlook at between 5 and 10, with 10 being the most optimistic, according to the quarterly Marcum CEO Survey. That compares with 96.51 percent in the second quarter and 99.17 percent in the first quarter.

CEOs who rated their outlook in the 1 to 4 range increased to 3.94 percent from 3.49 percent.

"Middle-market CEOs are clearly maintaining their favorable outlook, even if they are not quite as ebullient as earlier in the year," said Jeffrey M. Weiner, chairman and CEO of Marcum LLP, a national accounting and advisory firm.

The weighted average of all CEO responses was 7.55, which is up from 7.41 in the second quarter, but down from 7.77 in the first quarter Marcum said.

CEOs said their top investment priorities were talent recruitment (named by 35 percent), technology (named by 16 percent), physical plant expansion (named by 7 percent) and geographic expansion (named by 4 percent). The percentage of CEOs who said they do not plan to invest in their companies over the next year increased for the third consecutive quarter, doubling to 4 percent from 2 percent in the first quarter.

The CEOs surveyed represented 17 industry categories, with 251 of the respondents coming from companies with revenues of $1 billion or lower and 25 from companies with revenues of more than $1 billion, Marcum said.