BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
azee007
Calcite | Level 5

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User
Actually f8.3 is the same as 8.3 . you can use 8.3 too .

View solution in original post

9 REPLIES 9
Ksharp
Super User
CODE NOT TESTED


proc tabulate data=combination;
class flavor culture;
var time;
table flavor*culture, time*mean ;
run;

azee007
Calcite | Level 5
Thank you - I was not using the var statement... I thought table statement wld be enough -
Ksharp
Super User
Yeah. Same thing happened to me. Usually overlooked.
azee007
Calcite | Level 5

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;

 

 

 

Ksharp
Super User

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;
 


azee007
Calcite | Level 5
Thank you - now the code is exactly i was working on..I just wanted to know f=f8.3 - 8.3 i understood used for 3 decimal places.. But f=f is for format=flavour8.3?
Ksharp
Super User
Actually f8.3 is the same as 8.3 . you can use 8.3 too .
azee007
Calcite | Level 5
Noted with thanks.
ballardw
Super User

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.

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