difficulty in formatting a file.

a file containing following data (part of it)....

1907594 201012 31 11
5837737 201012 41 18
257402.88 201101 31 11
7500 201101 33 1
115618.5 201101 41 11
556330 201102 31 12
481783.5 201102 41 20
2827732.13 201103 31 71
85253 201103 33 2
4479588.07 201103 41 90
7120 201104 21 1

where col 1 is amount
col 2 is yyyymm
col 3 is status
col 4 is count

here i want to make different files containing different files (eg . one file containing data with status 31 & another for 41 &so on.)

afterwards for individual file thus crreated ...

file is to be created with unique date(col 2) and for those having repetitions col1 and col4 should be added.

output should look like..

firstly a file with staus 31

1907594 201012 31 11
257402.88 201101 31 11
556330 201012 31 12
2827732.13 201101 31 71

finally

(1907594 + 556330) 201012 31 (11+12)
(257402.88 + 2827732.13) 201101 31 (11+71)
------------------------------------

thanks

different files for different statuses:

awk '{ print > "file_" $3 }' < input

will create files like file_31 and so forth.

I'm not quite sure on the rest of your requirements. What constitutes a "repetition" when the dates must obviously be repeated already to belong in the same file?

thanks..

BUT

if there are three distinct status .....
then i want three different files containing rows of respective status.

to make it more clear i hv edited my output file in my previous post ......
plz refer

That's exactly what my code does -- it picks the filename based on the value of field 3, i.e. $3.

thanks a lot...

---------- Post updated at 06:35 PM ---------- Previous update was at 06:22 PM ----------

how to get my final output.....
addition of 1st and 4th col for same col2(yyyymm) ?????

as given at last in my first post.???