An early reference to counting sheep as a means of attaining sleep can be found in
Illustrations of Political Economy by
Harriet Martineau, from 1834: "It was a sight of monotony to behold one sheep after another follow the adventurous one, each in turn placing its fore-feet on the breach in the fence, bringing up its hind legs after it, looking around for an instant from the summit, and then making the plunge into the dry ditch, tufted with locks of wool. The process might have been more composing if the field might have been another man's property, or if the flock had been making its way out instead of in; but the recollection of the scene of transit served to send the landowner to sleep more than once, when occurring at the end of the train of anxious thoughts which had kept him awake." (vol. 7, pp. 117–118) An even earlier reference can be found in
Don Quixote by
Miguel de Cervantes, from 1605 (the exception being Cervantes substituting "
goats" for "sheep"): "Let your worship keep count of the goats the fisherman is taking across, for if one escapes the memory there will be an end of the story, and it will be impossible to tell another word of it." Cervantes probably adapted the story of counting goats from a story of counting sheep in the early twelfth-century Spanish work
Disciplina clericalis. The section The King and his Story-teller (section 12) uses the idea of counting sheep humorously. Similar stories are listed in the
Aarne–Thompson–Uther Index as ATU 2300, "Endless Tales" and are closely related to ATU 2301, "Corn Carried Away One Grain at A Time". Several late 19th-century writers mention the use of counting sheep in order to aid sleep; the period of the 1860s–70s appears to be when it became a commonplace term, for example in
Sabine Baring-Gould's
Through flood and flame (1868): "She turned her face to the wall with a weary sigh, and endeavoured, by counting sheep going through a hedge-gap, to trick sleep into closing her eyelids." Macfarlane, Alexander William wrote about the technique in
Insomnia and Its Therapeutics (1891). ==In popular culture==