Daily sleep quality affects drug craving, partially through indirect associations with positive affect, in patients in treatment for nonmedical use of prescription drugs.