Understanding the F_ variable in the output data sets created by PROC FREQ when using ODS OUTPUT


The ODS OUTPUT statement can create data sets for the ONEWAYFREQS and LIST output objects generated by PROC FREQ. This data set contains the original TABLES request variable and a variable named F_variable-name. This variable is also explained in Usage Note 5025, "New variables contain formatted values in ONEWAYLIST and ONEWAYFREQS data sets." If a format has been assigned to the variable, the formatted value is carried over to the output data set. This can be confirmed by running PROC CONTENTS. This is consistent with the behavior of the OUT= option to create an output data set. Whether unformatted or formatted, the variable and the F_variable-name have the same value.

If you want one of the values to display the internal value and one to display the formatted value, you can remove the format from the original variable with a null FORMAT statement as shown in the sample code below:

proc format;
   value agefmt 11-13='11-13'
                14-16='14-16';
run;

ods output onewayfreqs=tables;

proc freq data=sashelp.class;
  tables age;
  format age agefmt.;
run;

proc contents data=tables;
run;

proc print data=tables;
   format age;
run;

Click the Output tab to see the results.

If the format is removed from the variable and the format represents a range or multiple values, note that the internal value is now displayed as the lowest internal value of the range. This is the expected behavior.