Reportedly, Joyce Carol Oates opined:
First requirement of the writer is the ability to concentrate for long periods of time. Second, more urgent requirement, the wish to do so.
However, it appears that Oates may have put the cart [i.e., the ability to concentrate] before the horse [i.e., the wish to do so]. Does Patricia Highsmith and Malcolm Gladwell have better writing advice?
Patricia Highsmith, the author of The Talented Mr. Ripley, related that self-amusement is needed to concentrate for long enough to write a book:
The first person you should think of pleasing, in writing a book, is yourself. If you can amuse yourself for the length of time it takes to write a book, the publishers and the readers can and will come later [إِنْ شَاءَ ٱللَّٰهُ].
And Malcolm Gladwell advised that a writer has to possess a desire to tell a story:
You need to have a desire to tell the story. You need to be personally invested in some way.
Thus, it appears that if a writer is self-amused and\or is invested in his or her writing, then he or she will (organically) have the ability to concentrate consistently and for long enough to write a book(s).