I have 2 files.In the first file the $ symbol is present in the 43rd position and the 2nd file $symbol is present in the 399th position.
if the files have same value in the 43rd(first file) and 399th(2nd file) position then write that records in the output file.
This statement doesn't make any sense unless each file only has one record. Files consist of records. Do you want to compare the records in the two files by their relative record number (1 vs 1, 2 vs 2, etc) or by a key or what?
It isn't clear what you're trying to do and you haven't given enough information. You need to show an example (relevant fields only) of the records in each input file and the expected output records, and explain the "rules" for getting from input to output. Give the RECFM and LRECL of each input file and the starting position, length and format of each relevant field.