Hi!
I have DBF from a network program and I would like to get a new DBF with just 1 record from the DBF before based in a condition using max, I mean i want one record of the Network DBF which has de maximun value in one column to be stored alone in another DBF file, I was trying to do it with a matrix program but none of my tries have worked. Would you please tell me how to do it, if not, would you tell me wich commands or formulas I can use to do it reading the manual? Thanks.
Hi Jesus.
This can be done both with a Network or Matrix programs. You can do this in different ways, a possible way to do this is to have a variable storing the max value, then based on this variable, storing all the other column values to be written in output as temp variables, example script below for Matrix:
RUN PGM=MATRIX PRNFILE="{SCENARIO_DIR}\JTAAT0AC.PRN" FILEI RECI = "{SCENARIO_DIR}\test.dbf" FILEO RECO[1] = "{SCENARIO_DIR}\max_rec.dbf", fields = A, B, DISTANCE, CAPACITY, T0, LINKCLASS ; within the internal record loop (reci) _max_column_val = max(_max_column_val, ri.CAPACITY) if (ri.CAPACITY >= _max_column_val) ; if current record _max_A = ri.A _max_B = ri.B _max_DISTANCE = ri.DISTANCE _max_CAPACITY = ri.CAPACITY _max_T0 = ri.T0 _max_LINKCLASS = ri.LINKCLASS endif if (i = 0) ; end of reci file ro.A = _max_A ro.B = _max_B ro.DISTANCE = _max_DISTANCE ro.CAPACITY = _max_CAPACITY ro.T0 = _max_T0 ro.LINKCLASS = _max_LINKCLASS write reco = 1 endif ENDRUN