Hello,
I've data were I have for one reporting date several observations, but I only want keep the first one. I've just two alternative ways of doing this, but strangely I get different results.
Method 1
egen id=group(x1 x2 x3)
by id (x4),sort: keep if _n==1
Method 2
by x1 x2 x3 (x4), sort: keep if _n==1
I've used the first method because I wanted a unique id for each reporting date. Surprisingly, the two methods give different results. My dataset is pretty large, i.e. 80 million observations. I then tried it with a smaller subset and get the same results, i.e. the two methods are yielding the exact same result.
Am I missing something?
Thanks.
Related Posts with working of egen group
Plotting curves for hazard model with firm level stratificationDear all, I am running a stratified cox model on a firm-year dataset. The command i use is: stset y…
Making an average when there are more than two values in different lines (of the same ID)Hi, everyone I am struggling with restructuring my data. Below is the format of my data: PID stand…
Order studies within group by time in meta-analysis forest plotHi everyone I am working on a forest plot. I want to order the studies within each group by publica…
Stock Prices Technical Analysis Pattern Recognition using STATAHello everyone. I am trying to use STATA to detect technical analysis patterns in stock prices. Does…
new package twby available on SSC: create a cross-tabulation of graphsThanks to Kit Baum, a new package, twby, is now available on SSC. It is a prefix command for twoway …
Subscribe to:
Post Comments (Atom)
0 Response to working of egen group
Post a Comment