'I don't see an explanatory legend in SAS proc freq

I have a problem with the legend not being visible at cross tabulation in porc freq in SAS. How can I show it?

I see only a table: enter image description here

But I want to also see a legend: enter image description here

sas


Solution 1:[1]

PROC FREQ does not have a legend per se, but you can use the title statement to put some information there, or footer.

If you want better control, use PROC TABULATE which has substantial ability to customize the output, including the box option which places whatever information you want in the top-left corner of the table.

Solution 2:[2]

If you run the following:

proc template;
source Base.Freq.CrossTabFreqs;
run;

Then check your log, you should see:

define crosstabs Base.Freq.CrossTabFreqs;
    notes "Crosstabulation table";
    cellvalue Frequency Expected Deviation CellChiSquare TotalPercent Percent RowPercent ColPercent CumColPercent;
    header TableOf ControllingFor;
    footer NoObs Missing;

If you do not, that means that someone has modified your PROC FREQ base template and that's why it's not showing. In this case you would need to replace your default SAS installation templates by obtaining clean copies from a different source. It may also need to align with your SAS version.

If you have a colleague or different SAS installation that is operating as expected, you can run the PROC TEMPLATE above, then copy the code from the log and re-create the template as:

proc template;
<insert copied code from log>;
run;

And you probably realize, but this is why modifying templates is generally a last resort for customizing data/output and usually you should never modify the default templates.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Joe
Solution 2 Reeza