%macro imlmed (data=, /* input data set */ var=, /* variable list to calculate */ /* the median from */ out=); /* output data set */ proc iml; /* Read VAR into a temporary matrix. */ use &data var {&var}; read all into temp; /* Transpose the matrix, calculate the median, */ /* retranspose the matrix, and horizontally */ /* concatenate the median to the input matrix. */ median=temp||median(temp`)`; /* Create a matrix that contains the original */ /* variable names and a name for the median. */ /* This matrix will name the variables in the */ /* output data set. */ names={&var median}; /* Create a SAS data set that contains values from */ /* the input data set and values for the medians. */ create &out from median [colname=names]; append from median; quit; %mend imlmed;