Greetings,

I'm running Stata 15.1 on OSX and working with panel data. My goal is to assess temporal change in respondent religious identification. Data was collected at different months each year between 2014-2018. Not all respondents participated in each wave while some who did participate didn't consistently answer the religious-id question. I'd thus like to create a variable that allows me to identify respondents who completed the measure at least once in a given survey year. I'm thinking the following might work, but I wasn't sure:

Code:
egen religid_count=count(religid), by(caseid year)
I receive the following output upon tabulation:

Code:
tab count_religid

count_relig |
         id |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |     96,917       45.22       45.22
          1 |      8,452        3.94       49.16
          2 |     10,673        4.98       54.14
          3 |      9,909        4.62       58.76
          4 |     37,860       17.66       76.42
          5 |     13,687        6.39       82.81
          6 |      2,205        1.03       83.84
          7 |      4,563        2.13       85.97
          8 |     30,078       14.03      100.00
------------+-----------------------------------
      Total |    214,344      100.00
Does '1' in the table above signify respondents who completed the measure at least once per survey year? If not, I'd appreciate some help in creating the desired variable.

Below is sample data:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(religid caseid) float(year month)
 2 100197 2018 3
12 100260 2018 3
 1 100314 2018 3
 2 100363 2018 3
11 100446 2018 3
 1 100514 2018 3
 2 100588 2018 3
 1 100598 2018 3
 2 100604 2018 3
 1 100637 2018 3
 1 100734 2018 3
 1 100803 2018 3
 1 101224 2018 3
12 101322 2018 3
 1 101437 2018 3
 2 101472 2018 3
 1 101485 2018 3
10 101493 2018 3
10 102009 2018 3
 1 102198 2018 3
12 102584 2018 3
 1 102782 2018 3
11 102932 2018 3
12 103060 2018 3
 2 103094 2018 3
 2 103190 2018 3
 1 103256 2018 3
 1 103379 2018 3
 2 103406 2018 3
12 103414 2018 3
 2 103519 2018 3
12 103538 2018 3
 2 103611 2018 3
 2 103677 2018 3
 1 103897 2018 3
11 103956 2018 3
12 104210 2018 3
 1 104368 2018 3
 9 104491 2018 3
 1 104689 2018 3
 2 104727 2018 3
12 104937 2018 3
 2 105124 2018 3
 2 105205 2018 3
 2 105269 2018 3
10 105857 2018 3
 2 105959 2018 3
 9 106068 2018 3
 1 106180 2018 3
 1 106297 2018 3
 2 106444 2018 3
12 106590 2018 3
 1 106613 2018 3
 2 106885 2018 3
 1 107023 2018 3
 1 107268 2018 3
 2 107329 2018 3
 1 107668 2018 3
 1 108035 2018 3
 9 108169 2018 3
 1 108348 2018 3
 2 108435 2018 3
 1 108447 2018 3
 1 108592 2018 3
 2 108909 2018 3
 1 109143 2018 3
 2 109188 2018 3
11 109299 2018 3
 2 109319 2018 3
 2 109987 2018 3
 2 110041 2018 3
 1 110129 2018 3
 9 110261 2018 3
 1 110353 2018 3
10 110361 2018 3
 1 110550 2018 3
 3 111646 2018 3
 2 111665 2018 3
 1 111884 2018 3
12 111927 2018 3
12 112238 2018 3
 2 112371 2018 3
 2 112490 2018 3
12 112495 2018 3
 1 112517 2018 3
 1 112613 2018 3
 2 112715 2018 3
12 112984 2018 3
 1 112987 2018 3
11 113248 2018 3
 1 113274 2018 3
12 113412 2018 3
 1 113565 2018 3
 5 114058 2018 3
 1 114190 2018 3
 2 114197 2018 3
 1 114473 2018 3
12 114671 2018 3
 1 114797 2018 3
 1 114898 2018 3
end
Thanks in advance for your help!

-Zach