Literacy and numeracy standards among young Scots have improved slightly according to official figures.
Young girls perform better than boys at all levels
However, the National Statistics for five to 14-year-olds show that some older pupils are still struggling to master the basics of reading, writing and maths.
The figures show that younger children are making good progress.
But by the time they reach their second year of secondary school, almost half of all pupils do not meet the standard expected in maths and writing.
Attainment levels for five to 14-year-olds
89.3% at P3 (up 3.5% since 1999)
78.1% at P4 (up 6.4% since 1999)
79.9% at P6 (up 5.7% since 1999)
67% at P7 (up 5.9% since 1999)
55.3% at S2 (up 7.5% since 1999)
Education Minister Peter Peacock has welcomed the report but admitted that more work must be done.
He said: "More pupils are hitting the mark in critical subjects and gaining the foundations for success in later life.
"But we must not be complacent. We want to see attainment continue to improve and be more rigorously assessed.
"That is why we are consulting on a major overhaul of the assessment system to better support learning and boost attainment."
Mr Peacock said that new classroom procedures would place a greater emphasis on learning.
He also said that a new Scottish Survey of Achievement would provide a more comprehensive picture of attainment across the country.
Mr Peacock said the early years of secondary were a particular problem and that the executive had pledged to reduce the size of English and maths classes during these years.
He also announced efforts to tackle the gender gap in attainment through "imaginative classroom practices".
Scottish National Party leader John Swinney said the statistics revealed a worrying trend.
Mr Swinney said: "It's very clear that far too many children, an increasing number of children, are being left behind.
"It's very disturbing that amongst 12 and 13 year olds there has been a 50% increase in the number of pupils who aren't achieving the level we would expect of primary three pupils."
The figures showed that more girls reached target attainment levels for all subjects at all ages.
However, the difference between boys and girls was usually larger in the later primary and early secondary stages.
The gap was also larger for English reading and writing than mathematics.