Hi all,
I am trying to compute the quarterly variation in a list of stock prices ( variables "prccd" for the price and "cusip" for the specific stock ) using the information contained in the "date" variable, which is just a list of dates. Hence, the panel looks like this:
I am trying to obtain the result using the following code:
but was wondering if there is an easier way through making use of the information contained in the "date" variable.
Many thanks in advance for your help and support!
I am trying to compute the quarterly variation in a list of stock prices ( variables "prccd" for the price and "cusip" for the specific stock ) using the information contained in the "date" variable, which is just a list of dates. Hence, the panel looks like this:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str10 cusip float(date prccd) "000360206" 16072 18.93 "000360206" 16075 19.02 "000360206" 16076 19.29 "000360206" 16077 19.19 "000360206" 16078 19.21 "000360206" 16079 19.63 "000360206" 16082 19.5 "000360206" 16083 19.5 "000360206" 16084 20.41 "000360206" 16085 21.55 "000360206" 16086 22.03 "000360206" 16090 22.4 "000360206" 16091 22 "000360206" 16092 20.92 "000360206" 16093 21.37 "000360206" 16096 21.14 "000360206" 16097 21.28 "000360206" 16098 20.92 "000360206" 16099 19.04 "000360206" 16100 19.04 "000360206" 16103 19.3 "000360206" 16104 18.92 "000360206" 16105 18.7 "000360206" 16106 18.7 "000360206" 16107 19.12 "000360206" 16110 19.44 "000360206" 16111 19.45 "000360206" 16112 18 "000360206" 16113 19.62 "000360206" 16114 19.48 "000360206" 16118 18.92 "000360206" 16119 19.28 "000360206" 16120 19.801 "000360206" 16121 19.77 "000360206" 16124 19.83 "000360206" 16125 19.83 "000360206" 16126 19.78 "000360206" 16127 20 "000360206" 16128 20.02 "000360206" 16131 20.12 "000360206" 16132 20.42 "000360206" 16133 20.061 "000360206" 16134 20.18 "000360206" 16135 20.12 "000360206" 16138 20.07 "000360206" 16139 20.26 "000360206" 16140 20.14 "000360206" 16141 20.16 "000360206" 16142 20.43 "000360206" 16145 20.14 end format %td date
Code:
by cusip: gen trimester_return_daily = (prccd[_n+120]-prccd[_n])/prccd[_n]
Many thanks in advance for your help and support!
Comment