You can use the following basic syntax to calculate frequencies by group in SAS: proc freq data=my_data; by var1; tables var2; run; This particular syntax creates a frequency table for the values of the variable called var2, grouped by the variable called var1.