Hello, I am new in Stata.
I have stock price data of many companies. I would like to get the return by using this code gen return= price/ price[_n-1]-1, however when I perform it in my data it runs for all companies mixing them. I would like to know which code I have to use to generate this variable based on the company id since I need to get the daily returns by company. I tried this code bysort gvkey datadate: gen return= price/ price[_n-1] , but it did not solve my issue. I hope someone can help me. Thanks in advance.
(Stata 16.0)
Related Posts with Returns of different companies
Specifying xtpmg optimal lags (2 3 1 2)dear community, i am having trouble specifying the optimal lags (2 3 1 2) chosen by AIC in my pmg mo…
How to standardize Stata variables format before using -append- ?I have around 40 files that I would like to append together. However, two variables named a12 and a1…
Reshape wide with missing observationsHello, I am trying to reshape wide the dataset below. Basically i would like the months (January th…
Renaming each variable label as a substring of old labelI have a set of variables v1 through v154 that I want to relabel by excluding the first 16 character…
Can I define the cell contents of a table (or matrix)?New here, new to Stata (v17) I'm trying to create a table to later be exported to Excel. I would li…
Subscribe to:
Post Comments (Atom)
0 Response to Returns of different companies
Post a Comment