in reply to correlation between two inputt files
If I am reading your question correctly, you wish to join two files where they have common values in the second column (see join for the unix command line equivalent).
--MidLifeXis