Dear Statalists,
I am working on a project and hope to figure out how to find the max value of a range of one variable.
The specific work is as follows. I'm working on panel data. I hope to find a max value of one variable (var1) in a time range (from year1 to year(n+6)). I tried different ways but couldn't find a solution. The one that makes the most sense for me is as below.
gen maxvar1=max(var1[1]:var1[_n+6])
OR
bysort id: egen maxvar1=max(var1[1]:var1[_n+6])
But it reports "equation [1] not found". I tried other methods, but they don't work either. May I have your advice?
Many thanks,
Chenli
I am working on a project and hope to figure out how to find the max value of a range of one variable.
The specific work is as follows. I'm working on panel data. I hope to find a max value of one variable (var1) in a time range (from year1 to year(n+6)). I tried different ways but couldn't find a solution. The one that makes the most sense for me is as below.
gen maxvar1=max(var1[1]:var1[_n+6])
OR
bysort id: egen maxvar1=max(var1[1]:var1[_n+6])
But it reports "equation [1] not found". I tried other methods, but they don't work either. May I have your advice?
Many thanks,
Chenli
Comment