BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DebG
Obsidian | Level 7

 

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

TableF_var1var1FrequencyPercentCumFrequencyCumPercentF_var2var2F_var3var3
Table var111266.67266.67 . .
Table var144133.333100 . .
Table var2 .266.67266.6722 .
Table var2 .133.33310055 .
Table var3 .266.67266.67 .33
Table var3 .133.333100 .66

 

 

desired results from 

var1var2var3FrequencyPercent

Cumulative

Frequency

Cumulative

Percent

123266.67266.67
456133.333100
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

 

View solution in original post

2 REPLIES 2
ballardw
Super User

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.

Reeza
Super User

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

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 2788 views
  • 5 likes
  • 3 in conversation