The SAS Output Delivery System and reporting techniques

Freqs and means in same table?

Reply
N/A
Posts: 0

Freqs and means in same table?

Hello~ Is it possible to have both frequencies and means in the same table?

Specifically, I want to show the frequencies for a 5-point scale over several waves of data, with the mean reported in the bottom row. I have not found any code that would allow both to be generated in the same table. Any help would be great appreciated!
Super Contributor
Posts: 260

Re: Freqs and means in same table?

Posted in reply to deleted_user
Does this look like what you want ? Once again, this is just playing with punctuation in the TABLE statement : comma stands for separating lines and columns, space stands for contiguous information, and star stands for "within".
[pre]PROC TABULATE DATA = sashelp.class ;
CLASS sex age ;
VAR weight ;
TABLE (age*N weight*MEAN),sex ;
RUN ;[/pre]
If the bottom row is for "age mean" in the example, you need to duplicate the age variable -- a variable cannot be CLASS and VAR at the same time.
[pre]DATA work.class ;
SET sashelp.class ;
age2 = age ;
RUN ;
PROC TABULATE DATA = work.class ;
CLASS sex age ;
VAR age2 ;
TABLE (age*N="" age2="Mean age"*MEAN=""),sex ;
RUN ;
[/pre]
Olivier
N/A
Posts: 0

Re: Freqs and means in same table?

Thanks again for your quick reply. I found it very helpful, and I am close to generating the table I want, but am still unable to incorportate percentages into the table, with a mean score in the bottom row. (I should have been clearer in my original post.)

Here's the code I'm trying to manipulate, but SAS is saying "PctN base in not in table. A PctN crossing has no denominator":

proc tabulate data=mvr.ready_08_6Jun(where=(wave ge 230)) format=9.1 noseps formchar(1,8,2,3,4,5,6,7,9,10,11)='||----|+|---';
title 'Table 1';
format wave wave. q1 sat. total total.;
class wave q1 total;
var mq1;
table (q1*N*f=4.0 f=p8r6.0*pctn mq1="Mean"*mean=' '),wave/rts=35
box="Table 1. OVERALL SATISFACTION" misstext=' ';;
keylabel pctn = "(%)";
run;
N/A
Posts: 0

Re: Freqs and means in same table?

Posted in reply to deleted_user
I figured it out - a matter of adding another set of parentheses to account for the percentages and also the mean score. Thank you so much Olivier!
Ask a Question
Discussion stats
  • 3 replies
  • 129 views
  • 0 likes
  • 2 in conversation