I'd do all of the heavy lifting in your first sql step, then use proc freq, then transpose. e.g. (which produces your summary5 table). However, while I won't delete my post, I like @nehalsanghvi's solution better (i.e., simply including the count variable in your one proc sql step):
PROC SQL NOPRINT;
CREATE TABLE Summary AS
SELECT
trialB.Client,
trialB.Product_ID,
case
when (trialB.Weight-trialA.Weight) > 0 then 'Less_than'
when (trialB.Weight-trialA.Weight) < 0 then 'Greater_than'
when (trialB.Weight-trialA.Weight) = 0 then 'Same' else ''
end as condition
FROM WORK.trialB LEFT JOIN WORK.trialA ON (trialB.Product_ID = trialA.Product_ID);
QUIT;
proc freq data=Summary;
tables client*product_ID*condition/out=need (drop=percent);
run;
proc transpose data=need out=want (DROP=_:);
BY Client Product_ID;
ID Condition;
VAR COUNT;
RUN;
HTH,
Art, CEO, AnalystFinder.com
... View more