I would use PROC MEANS or PROC SUMMARY to pre-summarize the data. Use a VBARPARM instead of a VBAR to…