I started to do this and then realised I wasn't sure about exactly what we are aiming at. I initially thought we were looking for bases that sold all 3 commodities that were the closest to those guard bases and would trade with them. I just had another look at the spreadsheet and some others have started and I think may also be getting it wrong.
This is how I see it now after getting clarification from Xoria:
Guard bases currently have no prices for Food, Water and Oxygen. This looks silly because they would have to buy them from traders to keep the base going.
These prices need to be set to be similar to the prices paid in the systems nearest to them.
So, simply put, all we are doing is finding the CLOSEST base, in the CLOSEST system that has a price for all 3 commodities; not that also SELLS them, just has a price. The prices will then be used as a basis to set the prices in the guard base.
If necessary, where the closest base only has prices for 1 or 2 of them, add a column with the next nearest base that sells the 3rd one and make a note.
Example: Alexandria Base - Closest base is Planet Crete (Food:190, Oxygen:45, Water:195)
(Somebody has set this as being Freeport-9, which is further away, unless I am mistaken!)
Hopefully, I have got this right. Please correct me if I haven't. This is not about setting up trading routes, it is about making the guard bases look more realistic.