Stata counting substring
问题 My table looks like this: ID AQ_ATC amountATC . "A05" 1 123 "A05AA02" 2525 234 "A05AA02" 2525 991 "A05AD39" 190 . "C10" 1 441 "C10AA11" 4330 229 "C10AA22" 3100 . "C05AA" 1 441 "C05AA03" 130 The count for the full 8-character AQ_ATC codes is already correct. The shorter codes are unique in the table and are substrings of the complete 8-character codes (they represent the first x characters). What I am looking for is the count of the appearances of the shorter codes throughout the entire table.