merge same pattern lines together

Hi people...

I normally find with out any problem the solutions I need just by searching. But for this I'm not having any joy or jsut failing to adapt what I'ev found to work.

I have applciation report that doesn't allow for manipulation at creation so I want to do some post modifcation (make it easier to drop into Excel).

I have a file that follow this pattern

AAA - 123 - 99999 - 20100418
BBB - 32243 - 9999999 - 20100418
CCC - 789 - 99 - 20100418
AAA - 123 - 99999 - 20100419 
BBB - 32243 - 9999999 - 20100419 
CCC - 789 - 99 - 20100419
AAA - 123 - 99999 - 20100420
BBB - 32243 - 9999999 - 20100420
CCC - 789 - 99 - 20100420

But to pritify it i would want an output like

,20100418, 20100419, 20100420
AAA,123,124,123
BBB,32243,32243,32243
CCC,789,789,789

Amongst the many clever people here are there anysuggestions on getting this done (preferably in a shell script). This would have many more days and categorys i.e. AAA -> ZZZ

Cheers and beers,
Neil

cat file | tr -d " " | awk -F "-" '
{  id[$1]=sprintf("%s,%s",id[$1],$2)
   last[$4]=1
}
END {
        for (i in last) {
                printf ",%s",i
                }
        printf "\n"
        for (i in id) {
                printf "%s%s\n",i,id
                }

}'

Totally amazing....that is the wonder on the Internet (I wish i'd come up with that idea).

Thanks a load.....works a treat.

N
e
i
l