If that is the case then you need to use PROC FREQ:
proc freq data=dataset noprint;
tables var1*var2 / outexpected out=output_dataset;
run;
Option "outexpected" outputs the expected frequency in the dataset specified in option "out=".
To automate the calculations you could use a macro which takes the name of the dataset and the variables you want to cross-tabulate. Then you will have to use a DATA STEP to complete your calculations.