To handle headers use the example that is using the FILENAME= option and test if tsvfile=LAG(tsvfile). You will need to add two extra INPUT statements. One with trailing @ to make sure the name is updated so that name change can be detected. And one to skip the header when it has changed.

infile tsvs filename=tsvfile dlm='09'x ;
input @;
if tsvfile ne lag(tsvfile) then input;
input counter timestamp x y z filename;
casefile=tsvfile;