BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!
3 REPLIES 3
Olivier
Pyrite | Level 9
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
deleted_user
Not applicable
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;
deleted_user
Not applicable
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!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 624 views
  • 0 likes
  • 2 in conversation