Your script already formats the tables at the time it constucts them; the ORS variable evaluates to a newline (and changing it does not really solve anything, at least not trivially).
As a basic principle, you want something like (pseudocode)
Code:
separator= # nothing
for table in tables
print separator table.name
separator=tab # or suitable number of spaces, or something
done
print "\n"
separator= # nothing
for table in tables
print separator "-" x (lenght table.name) # print as many underlines as required
separator=tab # or suitable number of spaces, or something
done
print "\n"
for i=0 to (however long the longest table is)
separator= # nothing
for table in tables
print separator
if (table.value[i])
table.value[i]
else
print "" # print whitespace if we ran out of values for this table
separator=tab # or suitable number of spaces, or something
done
print "\n"
done
As you can tell, this entails changing your data structure drastically, and possibly even changing to a different language. (Perl or Python would be easier than awk for this I think.)
A less drastic solution would be to output each table to a temporary file and use
pr to print it in columnar format. On Linux, I use
pr -bt 3 to tabulate into three columns; other platforms offer slightly different options.