AWK - averaging $3 by info in $1

Hello,

I have three columns of data of the format below:
<name> <volume> <size>
a 2 1.2
a 2 1.1
b 3 1.7
c 0.7 1.9
c 0.7 1.9
c 0.7 1.8

What I want as output is:
<name> <volume/number of sizes recorded> <average size>
a 1 1.15
a 1 1.15
....

i.e. I want get an average of column three, the size, for each name, divide the volume by the number of records represented by the name and then print name, volume scaled by number of records per name and average size.

So far I have this, which doesn't run properly:

The challenge, as I see it, is to store information about the previous record in awk so that in looking at the next record it can decide whether to continue summing or stop, divide through to get the average, print and start over.

Any help would be greatly appreciated. Thank you,

Use nawk or /usr/xpg4/bin/awk on Solaris.

Assuming you want to exclude the first line:

awk 'END {
  printf "%s %.2f %.2f\n", \
    n, v/c, s/c
  }      
!_[$1]++ && c { 
  printf "%s %.2f %.2f\n", \
    n, v/c, s/c
  c = 0    
  }
NR > 1 { 
  n = $1
  v = $2
  s += $3
  c ++
    }' infile

Given your data:

$ cat file
<name> <volume> <size>
a 2 1.2
a 2 1.1
b 3 1.7
c 0.7 1.9
c 0.7 1.9
c 0.7 1.8
$ awk 'END {
  printf "%s %.2f %.2f\n", \
    n, v/c, s/c
  }
!_[$1]++ && c {
  printf "%s %.2f %.2f\n", \
    n, v/c, s/c
  c = 0
  }
NR > 1 {
  n = $1
  v = $2
  s += $3
  c ++
    }' file
a 1.00 1.15
b 3.00 4.00
c 0.23 3.20

Thank you very much for your help, it works and has saved me much time.

nawk '{
_1[$1]++
_2[$1]+=$3
_l[NR]=$0
a=NR
}
END{
for(i=1;i<=a;i++){
	split(_l,tmp," ")
	temp=sprintf("%s",tmp[1])
	print tmp[1]," ",tmp[2]/_1[temp]," ",_2[temp]/_1[temp];
   }
}' file