Ponyboy's nightmares began just after his parents were killed in a car crash. They seem to recur in instances where Ponyboy is having problems coping with the emotional stress caused by other tragedies in his life. Examples of this would be Bob's death, Johnny's accident and the possibility that he too will die, and lastly, his fear of being separated from his brothers.
"Soda began sleeping with me, and it stopped recurring so often, but it happened often enough for Darry to take me to a doctor. The doctor said I had too much imagination. He had a simple cure, too: Study harder, read more, draw more, and play football more. After a hard game of football and four or five hours of reading, I was too exhausted, mentally and physically, to dream anything."
The doctor's advice may have made Ponyboy sleep more soundly, but it would not have alleviated the fears or emotional problems he was going through at the time. Grief hits everyone differently. There is no one way to cope with the loss of your loved ones.