Good morning,

So here is my issue.
I have two columns of raw data (Col1 and Col2 in the image below). I want to generate with STATA a third and fourth column (c1 and c2 in the image below) that basically tells me how many times has the corresponding letter appeared before. It's easier to understand with and example and an image so, for example, in C16 (c1), I want to know how many times has A16 (J) appeared before in either Col1 or Col2 but not after. This is the Excel formula I used to achieve this =COUNTIF($A$1:A15,A16)+COUNTIF($B$1:B15,A16). Does this have an equivalent on STATA?

Here is the image of my scenario:



Thanks