It is not necessarily a derogatory term in modern useage, but almost always has negative connotations - ie " He's a real dag!" or as an adjective - " His clothes are daggy." Often it is used in relation to someone unfashionable.
The term "dag" is also a type of compliment as used between mates, both male and female. For example, "you dag" means you're a bud but your way of thinking sure is different from mine!
A real dag is the matted sheep droppings and dirt mixed with the wool on the sheep's backside. To clean the dags out of the wool means to clean the matted wool of droppings. It's also any long, dangling, matted part of the wool.
Dag may even refer to the long, matted, untidy and dirty parts of another animal's coat, e.g. dags on a long-haired dog, dags in a neglected horse's tail, etc.