Hi!
I have a dataset with prices of stocks. It is a data panel by Code (the ticker of the stock) and Date. For each Code in a Date I have a price for a stock.
I need to create a new variable with the maximum price of the last 60 days for each Code (each stock).
I am trying the command bysort Code: egen Maximo=max(Fechamento). However, I am getting only one value for each Code - the maximum value for that Code during all the time.
What I need is the maximum price for the stock in the last 60 days.
Thanks!
Related Posts with How to refers the last n rows or obs in Stata
create a matrix from single-observation valuesHello, Does anyone know if there is a simple way to create a matrix from single-observation values?…
Probit: iteration backed up problemHi guys, I am trying to run a diff in diff. Unfortunately, the probit regression is not running pro…
How to adjust right test statistics for weak instrument?Hi, I'm using instrumental variable to estimate a regression with IVLASSO. I have a problem with we…
Vertical and left justified added text to graphHi fellow Stata users! I'm making up a graph and would like some added text labels to be added that…
Questions about how to combine PSM and DIDHi. I am studying the impact of law on employment rates. In order to remove the selection bias, I am…
Subscribe to:
Post Comments (Atom)
0 Response to How to refers the last n rows or obs in Stata
Post a Comment