I am using ODS output OneWayFreqs which allows me to output several lines into one table. I'm wondering if there is something similar for multiple level proc freq.
This works and will output the results of all frequencies of the 3 variables.
ods output OneWayFreqs=test;
proc freq data=my_Data;
tables var1 var2 var3
/ missing ;
run;
I would like to do a combination of the data and I keep getting the error below when I try to cross tabulate the results.
WARNING: Output 'OneWayFreqs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used.
ods output OneWayFreqs=test;
proc freq data=my_Data;
tables var1 * var2 * var3
/ missing list;
run;
Does anyone know if there is a different ODS output that may provide similar results?
data my_data;
input var1 var2 var3;
cards;
1 2 3
4 5 6
1 2 3
;
run;
results from ods output OneWayFreqs
Table | F_var1 | var1 | Frequency | Percent | CumFrequency | CumPercent | F_var2 | var2 | F_var3 | var3 |
Table var1 | 1 | 1 | 2 | 66.67 | 2 | 66.67 | . | . | ||
Table var1 | 4 | 4 | 1 | 33.33 | 3 | 100 | . | . | ||
Table var2 | . | 2 | 66.67 | 2 | 66.67 | 2 | 2 | . | ||
Table var2 | . | 1 | 33.33 | 3 | 100 | 5 | 5 | . | ||
Table var3 | . | 2 | 66.67 | 2 | 66.67 | . | 3 | 3 | ||
Table var3 | . | 1 | 33.33 | 3 | 100 | . | 6 | 6 |
desired results from
var1 | var2 | var3 | Frequency | Percent | Cumulative Frequency | Cumulative Percent |
1 | 2 | 3 | 2 | 66.67 | 2 | 66.67 |
4 | 5 | 6 | 1 | 33.33 | 3 | 100 |
This example can give you an idea of how to get started getting this table together. You will need to adapt the code to your data set. It's for two variables, not sure how it will work with three....
ods output crosstabfreqs=summary;
proc freq data=sashelp.class;
table sex*(_all_);
run;
data long;
length variable $32. variable_value $50.;
set summary;
Variable=scan(table, 2, '*');
Variable_Value=strip(trim(vvaluex(variable)));
presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
keep sex variable variable_value frequency percent presentation;
label variable='Variable' variable_value='Variable Value';
run;
@DebG wrote:
I am using ODS output OneWayFreqs which allows me to output several lines into one table. I'm wondering if there is something similar for multiple level proc freq.
This works and will output the results of all frequencies of the 3 variables.
ods output OneWayFreqs=test;
proc freq data=my_Data;
tables var1 var2 var3/ missing ;
run;
I would like to do a combination of the data and I keep getting the error below when I try to cross tabulate the results.
WARNING: Output 'OneWayFreqs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used.
ods output OneWayFreqs=test;
proc freq data=my_Data;
tables var1 * var2 * var3/ missing list;
run;
Does anyone know if there is a different ODS output that may provide similar results?
data my_data;
input var1 var2 var3;
cards;
1 2 3
4 5 6
1 2 3
;
run;
results from ods output OneWayFreqs
Table F_var1 var1 Frequency Percent CumFrequency CumPercent F_var2 var2 F_var3 var3 Table var1 1 1 2 66.67 2 66.67 . . Table var1 4 4 1 33.33 3 100 . . Table var2 . 2 66.67 2 66.67 2 2 . Table var2 . 1 33.33 3 100 5 5 . Table var3 . 2 66.67 2 66.67 . 3 3 Table var3 . 1 33.33 3 100 . 6 6
desired results from
var1 var2 var3 Frequency Percent Cumulative
Frequency
Cumulative
Percent
1 2 3 2 66.67 2 66.67 4 5 6 1 33.33 3 100
The appropriate table for such is the ODS OUTPUT CROSSTABFREQS = instead of onewayfreqs.
The structure of the data set will be a bit different though because of the added complexity.
This example can give you an idea of how to get started getting this table together. You will need to adapt the code to your data set. It's for two variables, not sure how it will work with three....
ods output crosstabfreqs=summary;
proc freq data=sashelp.class;
table sex*(_all_);
run;
data long;
length variable $32. variable_value $50.;
set summary;
Variable=scan(table, 2, '*');
Variable_Value=strip(trim(vvaluex(variable)));
presentation=catt(frequency, " (", trim(put(percent/100, percent7.1)), ")");
keep sex variable variable_value frequency percent presentation;
label variable='Variable' variable_value='Variable Value';
run;
@DebG wrote:
I am using ODS output OneWayFreqs which allows me to output several lines into one table. I'm wondering if there is something similar for multiple level proc freq.
This works and will output the results of all frequencies of the 3 variables.
ods output OneWayFreqs=test;
proc freq data=my_Data;
tables var1 var2 var3/ missing ;
run;
I would like to do a combination of the data and I keep getting the error below when I try to cross tabulate the results.
WARNING: Output 'OneWayFreqs' was not created. Make sure that the output object name, label, or path is spelled correctly. Also, verify that the appropriate procedure options are used to produce the requested output object. For example, verify that the NOPRINT option is not used.
ods output OneWayFreqs=test;
proc freq data=my_Data;
tables var1 * var2 * var3/ missing list;
run;
Does anyone know if there is a different ODS output that may provide similar results?
data my_data;
input var1 var2 var3;
cards;
1 2 3
4 5 6
1 2 3
;
run;
results from ods output OneWayFreqs
Table F_var1 var1 Frequency Percent CumFrequency CumPercent F_var2 var2 F_var3 var3 Table var1 1 1 2 66.67 2 66.67 . . Table var1 4 4 1 33.33 3 100 . . Table var2 . 2 66.67 2 66.67 2 2 . Table var2 . 1 33.33 3 100 5 5 . Table var3 . 2 66.67 2 66.67 . 3 3 Table var3 . 1 33.33 3 100 . 6 6
desired results from
var1 var2 var3 Frequency Percent Cumulative
Frequency
Cumulative
Percent
1 2 3 2 66.67 2 66.67 4 5 6 1 33.33 3 100
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.