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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.