I have a dataset that has data that is pooled across different years.

At the moment, I would to like be able to identify the occupational codes which are common across two years (e.g. 2004 and 2005).

So for example, say in the year 2004 the following occupational codes are present:

0101
0102
0103
0104
0105

And in the year 2005, the following occupational codes are present:

0101
0102
1111
1112
1113

Is there a command/function in Stata which can tell me that only occupational codes "0101" and "0102" are present in both? Note that I can't use merge as I'm not using two different .DTA files - it's within the dataset.

Thanks