And an alternate solution:
proc summary data=have nway;
class SiteId SampleDate;
var Concentration;
output out=want (drop=_:) median=Med_conc n=SampleN;
run;
And I second @PeterClemmensen's thanks for good question style AND that the example data will create the desired output.
One advantage that Proc summary has that an SQL solution won't is the ability to create many summary statistic variables without having to explicitly name each one using the / autoname option. You may find this handy when you have 20 variables to summarize and want mean, median , max , min, n, std and IQR for each, plus the ability to get more quantiles than SQL allows if needed.
... View more