@MEL20 wrote:
data have; input Age Age_group $ Gender $ Weight_group $ Height_group $; datalines; 11 1 Male 1 2 12 1 Male 1 3 12 1 Male 1 2 21 2 Male 1 3 14 1 NA 1 2 13 1 Female 2 2 23 2 Female 2 2 21 2 Female 3 1 24 2 Female 3 4 23 2 Female 3 4 13 1 NA 3 1 ; run;
I am trying to get a table in following format:
Characteristic
Height group
Group 1
Group 2
Group 3
Group 4
Age
Mean
(standard deviation)
17.00
(5.66)
14.60
(4.83)
16.50
(6.36)
23.50 (0.71)
Age
Group 1
1 (50%)
4 (80%)
1 (50%)
0 (0%)
Group 2
1 (50%)
1 (20%)
1 (50%)
1 (100%)
Gender
Male
1(50%)
2(40%)
0 (0%)
2 (100%)
Female
0 (0%)
2(40%)
2 (100%)
0 (0%)
NA
1(50%)
1(20%)
0 (0%)
0 (0%)
Weight
Group 1
0 (0%)
3 (60%)
2(100%)
0 (0%)
Group 2
0 (0%)
2 (40%)
0 (0%)
0 (0%)
Group 3
2 (100%)
0 (0%)
0 (0%)
2(100%)
I can do this using two separate procedures:
proc means data=have maxdec=2; var age; class height_group; run;
proc freq data = have; table (age_group gender weight_group) * height_group; run;
I am looking for a way to do this in a single step.
None of the SAS statistical or report procedures will place two statistics into a single cell. I can get values as shown but not the layout with something like this as a "single step".
proc tabulate data=have;
class age_group gender weight_group height_group;
var age;
table age *(mean std)
(age_group
gender
weight_group)*(n colpctn)
, height_group
/misstext='0'
;
run;
Up to you to provide labels and maybe a custom format to show "Group x" instead of the value provided.
... View more