%macro dsmedian(var=,      /* variable list to calculate  */
                           /* the median from             */
                median=);  /* variable name of returned   */
                           /* median                      */

   array vars{*} &var;

     /* Assign the center of the variable list to CENTER. */
   center=(dim(vars) + nmiss(of vars{*}) + 1) / 2;

    /* Calculate median                                   */
   &median=mean(ordinal(floor(center), of vars{*}),
                ordinal(ceil(center), of vars{*}));
   drop center;
%mend dsmedian;

data medians;
   set choldata;
   %dsmedian (var=chol1-chol52, median=medchol)
run;