Hello,
I am attempting to execute a very simple command where I create a new variable for each id (appearing many times in my data) corresponding to the first year that id appears in the data. My code is as follows:
bysort id: egen(first_year)=min(year)
Year is a numerical variable. However, I am getting the error "( invalid name, r;198". I have run similar commands in Stata countless times without any issues, so I am not sure what the problem is.
I also tried
by id: egen(first_year)=min(year)
but was met with the same error.
Any ideas?
Thanks in advance,
Erik
Related Posts with Bysort Trouble
PCA with weights?Dear All, I was wondering if weights should be used with the PCA command when constructing an index …
Using Loops to Convert Strings With Letters to Numeric ValuesHello Stata Users :-) I have a dataset comprised of 71 variables containing responses to items on a…
Renaming VariablesI am using STATA 15. I have a large data set with multiple columns and rows. I am interested in two …
Two-part modeling: combination of LCA and LPAHi Statalists, I was trying to do a two-part modeling for my dataset, in which observed vars are ze…
[Help] Marginal effect on StataHi. My question is from Stata (15.1), but also requires some statistical knowledge, which is why I a…
Subscribe to:
Post Comments (Atom)
0 Response to Bysort Trouble
Post a Comment