Hey Everyone,
I have daily data on transactions from a point-of-sale system. I want to generate a variable that counts the number of distinct users who logged a transaction (who have a "user_id" in the system) by month and location. I am eventually going to collapse this data by month and want the value to carry over.
What is the best way to accomplish this task?
The idea maybe to do something like:
```
by user_id location monthlydate, sort: gen nvals = _n == 1
replace nvals = sum(nvals)
replace nvals = nvals[_N]
```
But I am not positive if this is what I want, and what is the best way to keep this value through the collapse code. Thank you in advance for your help! -Josh
I have daily data on transactions from a point-of-sale system. I want to generate a variable that counts the number of distinct users who logged a transaction (who have a "user_id" in the system) by month and location. I am eventually going to collapse this data by month and want the value to carry over.
What is the best way to accomplish this task?
The idea maybe to do something like:
```
by user_id location monthlydate, sort: gen nvals = _n == 1
replace nvals = sum(nvals)
replace nvals = nvals[_N]
```
But I am not positive if this is what I want, and what is the best way to keep this value through the collapse code. Thank you in advance for your help! -Josh
Comment