You either need to add more variables to your TABLES (PROC FREQ) statement, or you need to have some IF THEN PUTLOG....; logic to dump a condition where you are seeing blank/missing value result.
Also, you have an OUTPUT; statement in multiple DO / END loops, but notice that you cannot set variable values for both of the ANALYSIS variables used in the FREQ. So, as you loop through the first DO / END 39 times, the variable in the second DO / END loop will have a blank/missing value, correct?
Start out by adding more variables to your PROC FREQ TABLES statement, such as:
PROC FREQ;
TABLES VARA*VARB*VARC / LIST MISSING;
RUN;
You should be abe to see better under what conditions you are getting the blanks.
Also, you may want to just STOP; at the end of the DATA step and then do a simple PROC PRINT -- work with test-data scenarios - SMALL ONES first before trying to conquer all conditions in your data. Most of all you really need to know your data and the SAS programming logic you intend to use, whether you developed the code or inherited it from someone else.
Scott Barry
SBBWorks, Inc.