I want to assign a dummy if the id (1,2,...13000) is smaller than a
threshold
(5000) from another dummy
gen memberh=(id<=sum(member))
But it doesn't work for some reason, it seems sum(member) is always
1, but why?
Recall that generate's sum function is a RUNNING sum, not the total
of member. You want egen sum to generate a variable that is a
constant across obs. Using auto,
g junk = (price < sum(price))
will be zero in the first obs and 1 thereafter.
But rather than creating a new variable, why not just
summarize member,meanonly
g memberh = (id < =r(sum))