Your explanation of the problem seems to be silent on the matter of would you ever need to have frequencies of, for example, code_1 with explanation_3.
Assuming you don't need that, this is a brilliant example of a situation where a long data set (which you don't have) makes the solution much simpler than having a wide data set (which you have). By structuring the data properly, you can then write very simple code to get the results you want.
proc freq data=long;
tables code*explanation/list missing;
/* Optional, use out=counts in the above statement after 'missing' to get a SAS data set with the counts */
run;
So how could you get this long data set? The best way is to NOT create the wide data set in the first place, create the long data set in the first place. But sometimes data comes from Excel or other places and it is wide to begin with. So here is code to create the long data set.
data long;
set db;
array c code_1-code_3;
array e explanation_1-explanation_3;
do i=1 to dim(c);
code=c(i);
explanation=e(i);
output;
end;
keep code explanation;
run;
Important concept: almost all SAS data analysis procedures are designed to work with long data sets. Avoid wide data sets, always use long data sets and transform the data to long if necessary.
--
Paige Miller