In reply to Ian Wakeling.

You must have read my mind! I started to write a section about how to use design matrices for descriptive statistics, but the article became too long. In addition to your cross-tabulation trick, you can use the dummy variables to compute univariate means and standard deviations for continuous variables for each level of the classification variable. The following example computes the means and standard deviation for the MPG_City variable for each TYPE of vehicle in the Sashelp.Cars data. There are no loops, so this trick is competitive with UNIQUE-LOC trick for BY-group analysis.

proc iml;
use sashelp.cars;
read all var "Type" into c;
read all var "MPG_City" into mpg;
close sashelp.cars;

D = design(c);
cat = unique(c);

/* want simple statistics for each kind of vehicle? Look, Ma, no loop! */
n = D[+, ]; /* counts for each level */
M = mpg # D; /* split contin var by classification levels */
mean = M[+, ] / n;
var = (M - mean#D)[##, ] / (n-1);
stddev = sqrt(var);
print (n // mean // stddev)[c=cat r={N "Mean" "Std Dev"}];