Hello all,

I have a dataset on user ratings of golf courses and I am trying to create a dummy variable called "compared_rating". Here is what I want the variable to look like:
  • compared_rating = 0 if that review made on a day when that user made no other reviews
  • compared_rating = 1 if that review made on days when that user made >1 review
In the data that I have, users can either create a new review or update an older one. With the compared_rating variable I am primarily interested in tracking if there is a creation and 1(+) update(s) on the same day or two+ updates on the same day. It would be ideal to also include users that have created two+ reviews on the same day in the compared_rating variable but this is less important.

This is my initial intuition for creating this variable:
PHP Code:
sort userid updatedat createdat
quietly by userid updatedat createdat
gen dup cond(_N==1,0,_n)
gen compared_rating if dup != 0
replace compared_rating 
if dup == 
Unfortunately, the code above only has about 1,700 values for compared_rating = 1 which makes me believe that I am doing something wrong since this is a dataset with over 1.3 million total entries. I have attatched a data example to help you all get a better idea of the data I am working with. I appreciate all insights!

Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input str17 userid strL(updatedat createdat) double rating
"001544VKwW" "2020-08-20T15:26:13.310Z" "2020-08-20T15:26:13.310Z"   1
"001544VKwW" "2020-10-10T19:16:36.043Z" "2020-10-10T19:16:36.043Z"   5
"007pm3BK9b" "2019-09-08T22:14:07.698Z" "2019-09-08T22:14:07.698Z"   2
"007pm3BK9b" "2019-09-09T23:19:32.089Z" "2019-09-09T23:19:32.089Z" 3.5
"007pm3BK9b" "2019-09-14T20:39:25.065Z" "2019-09-14T20:39:25.065Z"   4
"007pm3BK9b" "2019-09-20T21:14:52.105Z" "2019-09-20T21:14:52.105Z"   4
"007pm3BK9b" "2019-09-20T22:58:02.317Z" "2019-09-20T22:58:02.317Z"   5
"007pm3BK9b" "2019-09-26T22:54:42.854Z" "2019-09-26T22:54:42.854Z"   4
"007pm3BK9b" "2019-10-04T15:46:39.163Z" "2019-10-04T15:46:39.163Z"   4
"007pm3BK9b" "2019-10-04T18:36:17.445Z" "2019-10-04T18:36:17.445Z" 3.5
"007pm3BK9b" "2019-10-07T22:58:08.831Z" "2019-10-07T22:58:08.831Z"   3
"007pm3BK9b" "2019-10-08T20:25:50.499Z" "2019-10-08T20:25:50.499Z" 3.5
"007pm3BK9b" "2019-10-08T22:38:23.154Z" "2019-10-08T22:38:23.154Z"   4
"007pm3BK9b" "2019-10-09T17:27:58.500Z" "2019-10-09T17:27:58.500Z"   5
"007pm3BK9b" "2019-10-09T20:01:01.182Z" "2019-10-09T20:01:01.182Z"   5
"007pm3BK9b" "2019-10-15T17:09:36.862Z" "2019-10-15T17:09:36.862Z" 3.5
"007pm3BK9b" "2019-10-15T18:51:09.289Z" "2019-10-15T18:51:09.289Z"   3
"007pm3BK9b" "2019-10-18T18:05:30.405Z" "2019-10-18T18:05:30.405Z"   3
"007pm3BK9b" "2019-10-20T21:17:03.182Z" "2019-10-20T21:17:03.182Z"   4
"007pm3BK9b" "2019-10-23T20:28:24.449Z" "2019-10-23T20:28:24.449Z"   5
"007pm3BK9b" "2019-11-18T01:31:13.733Z" "2019-11-18T01:31:13.733Z"   2
"009FmWLEeE" "2020-08-26T22:00:42.076Z" "2020-08-26T22:00:42.076Z"   5
"00BLGIWzcJ" "2019-05-15T00:30:45.612Z" "2019-05-15T00:30:45.612Z"   3
"00BLGIWzcJ" "2019-05-16T03:19:49.164Z" "2019-05-16T03:19:49.164Z"   4
"00BLGIWzcJ" "2019-05-31T00:18:37.680Z" "2019-05-31T00:18:37.680Z" 4.5
"00BLGIWzcJ" "2019-05-31T22:56:08.884Z" "2019-05-31T22:56:08.884Z"   5
"00BLGIWzcJ" "2019-06-06T01:18:30.047Z" "2019-06-06T01:18:30.047Z"   4
"00BLGIWzcJ" "2019-06-12T18:43:49.985Z" "2019-06-12T18:43:49.985Z" 1.5
"00BLGIWzcJ" "2020-02-17T21:00:45.484Z" "2020-02-17T21:00:45.484Z"   4
"00BLGIWzcJ" "2020-09-19T21:17:02.268Z" "2020-09-19T21:17:02.268Z" 4.5
"00BLGIWzcJ" "2020-10-15T01:46:14.302Z" "2020-10-15T01:46:14.302Z" 2.5
"00BLGIWzcJ" "2020-10-28T01:36:04.510Z" "2020-10-28T01:36:04.510Z"   4
"00BLGIWzcJ" "2020-11-01T16:20:27.406Z" "2020-11-01T16:20:27.406Z" 4.5
"00BLGIWzcJ" "2020-11-02T02:53:17.199Z" "2020-11-02T02:53:17.199Z"   5
"00BLGIWzcJ" "2020-11-02T02:54:47.077Z" "2020-11-02T02:54:47.077Z" 3.5
"00BLGIWzcJ" "2020-11-17T16:50:39.625Z" "2020-11-17T16:50:39.625Z"   5
"00BLGIWzcJ" "2020-11-17T20:04:32.899Z" "2020-11-17T20:04:32.899Z"   4
"00BLGIWzcJ" "2020-11-17T23:00:34.687Z" "2020-11-17T23:00:34.687Z"   4
"00BLGIWzcJ" "2020-11-22T18:51:21.183Z" "2020-11-22T18:51:21.183Z"   4
"00BLGIWzcJ" "2020-12-21T00:01:09.474Z" "2020-12-21T00:01:09.474Z" 3.5
"00BLGIWzcJ" "2020-12-22T04:52:20.770Z" "2020-12-22T04:52:20.770Z" 3.5
"00D0EXepFD" "2020-06-21T11:27:02.659Z" "2020-06-21T11:27:02.659Z"   5
"00D0EXepFD" "2020-07-02T15:26:11.556Z" "2020-07-02T15:26:11.556Z"   3
"00D0EXepFD" "2020-07-05T14:38:53.997Z" "2020-07-05T14:38:53.997Z"   4
"00D0EXepFD" "2020-07-06T11:05:02.099Z" "2020-07-06T11:05:02.099Z"   2
"00D0EXepFD" "2020-07-07T11:04:25.031Z" "2020-07-07T11:04:25.031Z"   4
"00D0EXepFD" "2020-07-10T10:07:39.704Z" "2020-07-10T10:07:39.704Z"   4
"00D0EXepFD" "2020-09-19T08:09:47.819Z" "2020-05-09T16:17:29.435Z"   4
"00FqmmCeLF" "2020-11-03T20:59:07.579Z" "2020-11-03T20:59:07.579Z"   5
"00FqmmCeLF" "2020-11-06T22:58:37.928Z" "2020-11-06T22:58:37.928Z"   5
"00GM0zPWrU" "2020-02-15T21:37:23.713Z" "2020-02-15T21:37:23.713Z" 4.5
"00GM0zPWrU" "2020-03-01T21:47:38.896Z" "2020-03-01T21:47:38.896Z"   4
"00GM0zPWrU" "2020-03-20T20:03:22.536Z" "2020-03-20T20:03:22.536Z"   4
"00GM0zPWrU" "2020-09-25T01:34:35.463Z" "2020-09-25T01:34:35.463Z"   5
"00GM0zPWrU" "2020-09-26T19:33:44.294Z" "2020-09-26T19:33:44.294Z"   4
"00GM0zPWrU" "2020-10-10T14:54:53.694Z" "2020-10-10T14:54:53.694Z"   4
"00GRD0DXsA" "2020-07-04T14:22:33.072Z" "2020-07-04T14:22:33.072Z" 3.5
"00GRD0DXsA" "2020-07-06T17:23:02.309Z" "2020-07-06T17:23:02.309Z"   4
"00GRD0DXsA" "2020-07-08T14:41:02.262Z" "2020-07-08T14:41:02.262Z"   4
"00GRD0DXsA" "2020-07-09T16:06:46.700Z" "2020-07-09T16:06:46.700Z"   4
"00I4u5rBjQ" "2017-10-17T12:54:28.220Z" "2017-09-10T01:07:47.692Z"   4
"00I4u5rBjQ" "2018-06-25T03:38:34.679Z" "2017-09-10T01:07:56.427Z" 2.5
"00IonREp6n" "2018-10-14T18:58:58.867Z" "2018-10-14T18:58:58.867Z"   5
"00LskfiGlk" "2020-05-19T22:54:16.392Z" "2020-05-19T22:54:16.392Z"   4
"00M2bF7aW1" "2020-06-30T17:06:22.024Z" "2020-06-30T17:06:22.024Z"   5
"00M2bF7aW1" "2020-07-15T23:53:41.959Z" "2020-07-15T23:53:41.959Z"   5
"00M2bF7aW1" "2020-08-17T22:15:15.140Z" "2020-08-17T22:15:15.140Z"   5
"00M9ISXXrC" "2018-11-27T15:41:18.681Z" "2018-11-27T15:41:18.681Z" 3.5
"00M9ISXXrC" "2018-12-08T19:59:12.883Z" "2018-12-08T19:59:12.883Z" 2.5
"00M9ISXXrC" "2018-12-13T20:04:55.256Z" "2018-12-13T20:04:55.256Z" 3.5
"00M9ISXXrC" "2018-12-13T21:58:36.894Z" "2018-12-13T21:58:36.894Z"   3
"00M9ISXXrC" "2018-12-28T18:56:12.788Z" "2018-12-28T18:56:12.788Z" 3.5
"00M9ISXXrC" "2019-07-14T18:51:41.578Z" "2019-07-14T18:51:41.578Z"   5
"00M9ISXXrC" "2019-11-07T18:32:29.926Z" "2019-11-07T18:32:29.926Z"   5
"00M9ISXXrC" "2020-05-26T17:51:07.521Z" "2020-05-26T17:51:07.521Z"   5
"00M9ISXXrC" "2020-06-17T09:48:45.849Z" "2018-05-28T17:44:51.120Z"  .5
"00M9ISXXrC" "2020-08-27T23:23:25.689Z" "2018-09-20T00:03:45.160Z" 3.5
"00M9ISXXrC" "2020-11-29T17:32:09.222Z" "2020-11-29T17:32:09.222Z"   4
"00OFXMYGwM" "2020-09-11T15:28:47.021Z" "2020-09-11T15:28:47.021Z" 4.5
"00OFXMYGwM" "2020-10-21T14:29:34.250Z" "2020-07-25T01:05:27.775Z"   5
"00OqHKXhlZ" "2020-09-10T02:03:45.776Z" "2020-09-10T02:03:45.776Z"   3
"00P0wOQrpc" "2020-08-14T12:03:49.138Z" "2020-08-14T12:03:49.138Z"   5
"00P0wOQrpc" "2020-09-03T20:13:28.203Z" "2020-09-03T20:13:28.203Z"   4
"00P0wOQrpc" "2020-09-26T17:06:49.386Z" "2020-06-15T12:48:28.137Z" 3.5
"00P0wOQrpc" "2020-09-27T12:06:28.200Z" "2020-09-27T12:06:28.200Z"   3
"00P0wOQrpc" "2020-10-16T12:07:26.127Z" "2020-10-16T12:07:26.127Z" 4.5
"00QpTCKkvk" "2018-05-21T16:09:36.829Z" "2018-05-21T16:09:36.829Z"   4
"00ROkedpRn" "2020-10-11T21:57:36.182Z" "2020-10-11T21:57:36.182Z"   4
"00ROkedpRn" "2020-10-12T22:52:53.616Z" "2020-10-12T22:52:53.616Z" 4.5
"00ROkedpRn" "2020-11-20T18:44:56.250Z" "2020-11-20T18:44:56.250Z"   4
"00ROkedpRn" "2020-12-22T19:01:57.296Z" "2020-12-22T19:01:57.296Z"   4
"00ROkedpRn" "2020-12-23T18:35:37.114Z" "2020-12-23T18:35:37.114Z"   4
"00ROkedpRn" "2020-12-27T20:04:22.402Z" "2020-12-27T20:04:22.402Z"   4
"00ROkedpRn" "2020-12-28T19:25:49.071Z" "2020-12-28T19:25:49.071Z"   5
"00SGfJeiLC" "2020-05-24T21:41:50.669Z" "2020-05-24T21:41:50.669Z"   5
"00SGfJeiLC" "2020-07-04T19:45:34.921Z" "2020-07-04T19:45:34.921Z"   5
"00SGfJeiLC" "2020-07-18T16:37:40.389Z" "2020-07-18T16:37:40.389Z"   5
"00SGfJeiLC" "2020-08-22T00:30:23.378Z" "2020-08-22T00:30:23.378Z"   5
"00TAAjSt8W" "2019-07-27T20:47:41.636Z" "2019-07-27T20:47:41.636Z"   4
"00TAAjSt8W" "2019-07-28T17:26:58.591Z" "2019-07-28T17:26:58.591Z"   3
end