I'm expecting that a gene might have more than snpID,
and there might be genes that don't have snps it will be NA
and there might be one snpID for pre one gene
would work, but since absolutely none of the positions specified in your 1st sample input file are in any of the ranges specified by your 2nd sample input file, no output is produced. I guess that is to be expected because I asked you what output you wanted your script to produce from your sample input files and you didn't give an answer to that question.
If this doesn't work for your real data, you might consider giving us some sample input that you think should produce some output and actually show us what output you are trying to produce from those inputs.
If you want to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk or nawk .
One last time: Please show us exactly what output you want your code to produce when given the input files your provided in post #1 in this thread. If you are unwilling to do that, I'll close the thread.
No you have not. None of the data shown in the columns of the output you said you wanted in post #5 and in post #7 (even if the asterisks are removed) in this thread:
genename SNPID chrom position txstart txend
show up anywhere in either of the sample input files shown in post #1 except for the chrom field.
This thread is closed!
Please consider opening a new thread where you show us two small sample input files and show us the exact output that you want your script to produce from those sample input files. Make sure that the data given in those files includes data that tests all of your corner cases and be sure that your description clearly specifies what should happen if multiple values match, what should happen if no values match, what should happen if one value matches, and any special cases that haven't been identified so far by this list.