BackgroundWith the availability of health insurance claim data, pharmacovigilance for various drugs has been suggested; however, it is necessary to establish an appropriate analysis method. To detect unintended drug effects and to generate new hypotheses, we conducted a hypothesis-free study to systematically examine the relationship between all prescription nonanticancer drugs and the mortality of colorectal cancer patients.MethodsWe used the Korean National Health Insurance Service-National Sample Cohort database. A total of 2,618 colorectal cancer patients diagnosed between 2004 and 2015 were divided into drug discovery and drug validation sets (1:1) through random sampling. Drugs were classified using the Anatomical Therapeutic Chemical (ATC) classification system: 76 drugs classified as ATC level 2 and 332 drugs classified as ATC level 4 were included in the analysis. We used a Cox proportional hazard model adjusted for sex, age, colorectal cancer treatment, and comorbidities. The relationship between all prescription nonanticancer drugs and the mortality of colorectal cancer patients was analyzed, controlling for multiple comparisons with the false discovery rate.ResultsWe found that one ATC level-2 drug (drugs that act on the nervous system, including parasympathomimetics, addictive disorder drugs, and antivertigo drugs) showed a protective effect related to colorectal cancer prognosis. At the ATC level 4 classification, 4 drugs were significant: two had a protective effect (anticholinesterases and opioid anesthetics), and the other two had a detrimental effect (magnesium compounds and Pregnen [4] derivatives).ConclusionsIn this hypothesis-free study, we identified four drugs linked to colorectal cancer prognosis. The MWAS method can be useful in real-world data analysis.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12885-023-11105-9.