The solution put together by @Astounding and @Kurt_Bremser ended up working nicely in my situation. I wanted to use proc means to count distinct values because I am utilizing the types statement to get a variety of summary rows, which wouldn't work as easily in other procedures. My implementation looked something like this: proc means data=input_data noprint;
class category subcategory subject;
types category*subcategory*subject category*subject subject;
output out=data1(rename=_type_=type) n=n;
run;
proc means data=data1 noprint nway missing;
class category subcategory type;
var n;
output out=data2(drop=_:) n=n sum=sum;
run; In fact, with that method, I was able to to get both a count of distinct subjects (the n column in data2) and a count of all rows (the sum column in data2).
... View more