Good on ya' to recognize the futility of the approach! :)
See
doc splitapply
for the general utility function to apply a function to groups of data within a table.
doc findgroups
will let you get the group ids and use it independently as well.
One key point; in a table such as you have, the SampleName variable should be of the categorical type for efficiency; makes lookup and testing much simpler than with string variables. Also, if the variable name is such that there are actually two variables combined (that is, the '1' and the 'C' may both have different values, then you should separate those into two variables so that can group over either the letter mnemonic or the numeric value. If they're all always 'nC' where the 'C' is invariant, then it doesn't matter.
After that, instead of creating three separate tables A, B, C, either merge those into one table with another variable that is the identifier if need to keep them separate or just read the data in one-at-a-time if all analyses are within a single table rather than across tables, and use a generic name for the table.