i want to use the tabulate procedure to display the average time for each flavor and culture combination. I am not able to get the average time for each. I have tried few steps... plz suggest how to tabulate to get desired results
Available data;
Obs flavor culture time
1 blueberry L.acidophilus 1.25381
2 blueberry L.acidophilus 1.19350
3 plain L.acidophilus 1.08703
4 plain L.acidophilus 1.40896
5 plain L.acidophilus 2.63547
6 plain L.acidophilus 2.69992
7 strawberry L.acidophilus 3.01486
8 strawberry L.acidophilus 3.35383
9 strawberry L.acidophilus 3.71758
10 strawberry L.acidophilus 3.38742
11 vanilla L.acidophilus 4.15288
12 vanilla L.acidophilus 4.34319
13 vanilla L.acidophilus 4.12448
14 blueberry B.bifidum 1.02099
15 blueberry B.bifidum 1.46241
16 blueberry B.bifidum 0.78172
17 plain B.bifidum 1.59875
18 plain B.bifidum 1.72159
19 cherry B.bifidum 2.38972
20 cherry B.bifidum 2.27279
21 vanilla B.bifidum 3.17874
22 vanilla B.bifidum 3.06254
23 vanilla B.bifidum 3.20867
proc tabulate data=combination;
class flavor culture;
table flavor culture;
run;
CODE NOT TESTED proc tabulate data=combination; class flavor culture; var time; table flavor*culture, time*mean ; run;
Dear Ksharp,
The table i wanted to create was cross-tabulation of the flavor and culture - so I wanted to have the flavors in the rows of the table and separate columns for the two cultures. This would create both the mean and row headers.
The table created by the code below have only the statistic header for means.
Moreover, want also to control of the header labels -want to remove the summary statistic (mean)
and row variable headers from the table.
plus the answers to 3 decimal places.
CAN YOU PLEASE GUIDE--
proc tabulate data=yogurt;
class flavor culture;
var time;
table flavor*culture, time*mean ;
run;
data have; infile cards expandtabs truncover; input Obs flavor : $20. culture : $20. time; cards; 1 blueberry L.acidophilus 1.25381 2 blueberry L.acidophilus 1.19350 3 plain L.acidophilus 1.08703 4 plain L.acidophilus 1.40896 5 plain L.acidophilus 2.63547 6 plain L.acidophilus 2.69992 7 strawberry L.acidophilus 3.01486 8 strawberry L.acidophilus 3.35383 9 strawberry L.acidophilus 3.71758 10 strawberry L.acidophilus 3.38742 11 vanilla L.acidophilus 4.15288 12 vanilla L.acidophilus 4.34319 13 vanilla L.acidophilus 4.12448 14 blueberry B.bifidum 1.02099 15 blueberry B.bifidum 1.46241 16 blueberry B.bifidum 0.78172 17 plain B.bifidum 1.59875 18 plain B.bifidum 1.72159 19 cherry B.bifidum 2.38972 20 cherry B.bifidum 2.27279 21 vanilla B.bifidum 3.17874 22 vanilla B.bifidum 3.06254 23 vanilla B.bifidum 3.20867 ; run; proc tabulate data=have; class flavor culture; var time; table flavor='',culture*time=''*mean=''*f=f8.3 ; run;
I tend to think of F8.3 as Fixed, 8 columns and 3 decimal places. I think that way because I've been involved with enough projects reading data with the F8.3 format where the decimals are IMPLIED and inserted at read. I also use the F habitually to make sure that I am using the intended format not z8.3 or something else.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.