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
New Stata module for robust estimation of production functionsA new Stata module for robust estimation of production functions is now available at the SSC archive…
Summing a row for one observation onlyDear all, I would like to sum values that are in the same row but on different columns. For instanc…
Multi-level multiple imputation in a longitudinal dataset with three levelsI have a longitudinal dataset that is hierarchical in nature with repeated measures of outcomes take…
foreach and if condition: if not found r(111);Hi, I am trying to loop through a list of variables to replace some values of variables named "varA…
coefplot: point estimates + significance levelsDear Stata users, I am using -coefplot- to vizualize average marginal effects. I am looking a way h…
Subscribe to:
Post Comments (Atom)
0 Response to working of egen group
Post a Comment