Data analysis
SD, pain
The sample size was calculated based on the primary outcome of this study, the total cumulative dose of propofol during ERCP procedure. A placebo-controlled pilot study of 20 patients showed the mean ± standard deviation (SD) of administered dose of propofol during procedure was 207.4 ± 73.7 mg. We anticipated a 20% difference in propofol needs between the placebo group and the magnesium sulfate group (less propofol consumption in magnesium sulfate group). By setting a two-sided alpha of 0.05 and a beta error of 0.1, a minimum of 34 patients in each group would be required to allow the detection of a difference between groups with a power of 90%. In our study, 40 elderly patients were recruited in each group for possible dropouts.Statistical analysis was performed by SPSS version 25.0 (SPSS Inc, Chicago, Illinois, USA). Continuous variables, including physiological parameters, total cumulative dose of propofol, duration of procedure, awakening and recovery time, pain score at 30 min after ERCP, as well as satisfaction of the endoscopists and patients were presented as mean ± SD or medians with the upper and lower quartiles, whereas categorical variables were expressed as frequency and percentages. Shapiro-Wilk’s test was used to assess the data distribution. Continuous variables were compared between groups by the independent samples 