Programming the statistical procedures from SAS

Question about two-dimensional table

Reply
N/A
Posts: 0

Question about two-dimensional table

I have an example data,like follows:
data patients;
input ID $ 1-4 Name $ 6-16 Sex $ 18 Age 20-21
Date 23-24 Height 26-27 Weight 29-31
ActLevel $ 33-36 Fee 38-43;
format fee 6.2;
datalines;
2458 Murray, W M 27 1 72 168 HIGH 85.20
2462 Almers, C F 34 3 66 152 HIGH 124.80
2523 Johnson, R F 43 31 63 137 MOD 149.75
2539 LaMance, K M 51 4 71 158 LOW 124.80
2544 Jones, M M 29 6 76 193 HIGH 124.80
2552 Reberson, P F 32 9 67 151 MOD 149.75
2555 King, E M 35 13 70 173 MOD 149.75
2563 Pitts, D M 34 22 73 154 LOW 124.80
2571 Nunnelly, A F 44 19 66 140 HIGH 149.75
2572 Oberon, M F 28 17 62 118 LOW 85.20
2574 Peterson, V M 30 6 69 147 MOD 149.75
2575 Quigley, M F 40 8 69 163 HIGH 124.80
2578 Cameron, L M 47 5 72 173 MOD 124.80
2586 Derber, B M 25 23 75 188 HIGH 85.20
2588 Ivan, H F 22 20 63 139 LOW 85.20
2589 Wilcox, E F 41 16 67 141 HIGH 149.75
2595 Warren, C M 54 7 71 183 MOD 149.75
;
run;

Then I create a two-dimensional table,like follows:
proc tabulate data=patients
style=[font_weight=bold];
class actlevel;
classlev actlevel / style=[just=left];
var age height weight / style=[font_size=3];
keyword all sum / style=[font_width=wide];
keylabel all="All Patients";
table (actlevel="Activity Level"
all*[style=[background=yellow]]),
(age height weight*f=best10.2)*mean /
style=[background=white]
misstext=[label="Missing"
style=[font_weight=light]]
box=[label="Patient Info by Activity Level"
style=[font_style=italic]];title 'Enhanced Table';
run;

The result is follows:
---------------------------------------------------------------------
|Patient Info by Activity Level| Age | Height | Weight |
| |------------+------------+----------|
| | Mean | Mean | Mean |
|------------------------------+------------+------------+----------|
|Activity Level | | | |
|------------------------------| | | |
|HIGH | 34.29| 70.14|163.571429|
|------------------------------+------------+------------+----------|
|LOW | 33.75| 67.25| 142.25|
|------------------------------+------------+------------+----------|
|MOD | 40.17| 68.67|160.666667|
|------------------------------+------------+------------+----------|
|All Patients | 36.24| 68.94|157.529412|
---------------------------------------------------------------------

I don't understand following two parts:
1) the value 'All Patients',how to calculate it? example how to get the result '36.24'?
2) (age height weight*f=best10.2)*mean / ,what is the meaning of 'weight*f=best10.2'? How to get the result '163.571429'?

Thanks Message was edited by: EdwardKing
SAS Super FREQ
Posts: 8,683

Re: Question about two-dimensional table

Hi:

Proc Tabulate uses the class variable ALL to allow you to request a statistic in any dimension of your table. For example, if you had SUM, as the statistic, then ALL would be the SUM statistic. Since you have MEAN as the statistic, then what you see on the line "All Patients" is the GRAND MEAN for Age, Height and Weight across all Activity Levels.

You can verify that this is the grand mean by running a PROC MEANS to verify the numbers:
[pre]

proc means data=patients mean;
class actlevel;
var age height weight;
ways (0 1);
run;
[/pre]

Since PROC MEANS shows you the N or count that went into the calculation of these means, you can verify the numbers with a calculator.

As for question #2, the number: 163.571429 is the mean of the WEIGHT variable for the HIGH Activity Level. You can verify this number, also with the PROC MEANS output. The difference between PROC MEANS and PROC TABULATE is that PROC TABULATE gives you the syntax to control the arrangement of the dimensions in the table.

The syntax *f=best10.2 tells PROC TABULATE what format to apply to the calculated statistic. I'm not sure why you're applying the BEST format. You could try either of these (F= and FORMAT= are the same thing):
[pre]
weight*format=10.2
weight*f=comma10.1
[/pre]

The number of decimal points can be controlled using the number after the period in the format specification.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 59 views
  • 0 likes
  • 2 in conversation