Dear All
Can you all help with a code to get the number of unique visits in each district. For example I have a dataset where the number of rows is the number of places visited for each district but for the same visit on the same month the number of rows is more than one since the places are different. How can I use the information on day month and year to get the number of unique visits made by a person. So for example if the year is 2015, month is 10 and dates are 16, 18, 20, 23.. the number of visit should be one taking a threshold of 5 days. that is If the data of visit for the next place is within 5 days or less it should be counted as 1 visit and if its more than 5 then 2 visits. Can you help me with a code to do that.
example of my data set
copy starting from the next line ------ ----------------
Can you all help with a code to get the number of unique visits in each district. For example I have a dataset where the number of rows is the number of places visited for each district but for the same visit on the same month the number of rows is more than one since the places are different. How can I use the information on day month and year to get the number of unique visits made by a person. So for example if the year is 2015, month is 10 and dates are 16, 18, 20, 23.. the number of visit should be one taking a threshold of 5 days. that is If the data of visit for the next place is within 5 days or less it should be counted as 1 visit and if its more than 5 then 2 visits. Can you help me with a code to do that.
example of my data set
copy starting from the next line ------ ----------------
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte(district q1) int(q2 q3) 1 28 12 2016 1 9 5 2018 2 3 3 2007 2 26 10 2015 2 15 9 2015 2 19 10 2015 2 26 10 2015 2 25 10 2015 2 21 10 2015 2 18 10 2015 2 18 10 2015 2 23 10 2015 2 16 10 2015 2 19 10 2015 2 19 10 2015 2 9 10 2019 3 21 11 2012 3 22 11 2012 3 21 11 2012 3 30 11 2013 3 30 7 2013 3 1 4 2014 3 1 4 2014 4 25 10 2016 4 16 10 2016 4 8 8 2018 4 6 7 2018 5 20 9 2011 5 23 12 2017 5 7 9 2017 5 19 12 2017 5 17 12 2017 5 14 10 2017 5 22 12 2017 5 13 10 2017 5 22 12 2017 5 15 9 2017 5 21 12 2017 5 16 12 2017 5 20 12 2017 6 12 3 2008 6 31 3 2009 6 24 3 2009 6 14 3 2009 6 27 3 2009 6 30 3 2009 6 30 3 2009 6 12 3 2009 6 26 3 2009 6 25 3 2009 6 28 3 2009 6 26 3 2009 6 11 3 2009 6 25 3 2009 6 16 3 2009 6 25 3 2009 6 29 3 2009 6 13 3 2009 6 25 3 2009 6 31 3 2009 6 12 3 2009 6 26 3 2009 6 14 3 2009 6 17 3 2009 6 25 3 2009 6 14 3 2009 6 14 3 2009 6 14 3 2009 6 15 3 2009 6 21 1 2015 6 21 1 2015 6 21 1 2015 6 13 6 2016 6 13 5 2018 6 14 5 2018 6 13 5 2018 6 12 5 2018 6 11 5 2018 7 12 6 2009 7 13 6 2009 7 13 6 2009 7 12 6 2009 7 14 6 2009 7 11 6 2009 7 14 6 2009 7 11 11 2009 7 10 1 2010 7 20 3 2010 7 5 7 2014 7 5 2 2014 7 22 6 2016 7 22 4 2017 7 21 4 2017 7 16 1 2018 7 8 1 2018 7 10 5 2018 7 14 1 2018 7 21 8 2018 7 27 5 2018 7 13 1 2018 end label values district dcode
Comment