Hi Ksharp
Thanks for getting back to me so quickly!
May I please ask whether the variable: "mean_two_year_before" represents the average SDEV for a specific company (permno) across the two years prior to the DISTCD 1262 or 1272 date? Also whether "mean_two_year_after" represents the average SDEV for a specific company (permno) across the two years after the DISTCD 1262 or 1272 date?
As I am thinking of creating the following variable: "mean_two_year_before" - "mean_two_year_after" = DIFF
-Katy
Yes.
the variable: "mean_two_year_before" represents the average SDEV(two_year_before) for a specific company (permno) across the two years prior to the current observation's DISTCD 1262 or 1272 date?
Ok thank you so much K sharp.
If it is ok with you, may I please ask one final question. I would like to ask, how would the code change if we remove the 1262 and 1272 restriction?
That is, for each PERMNO calculate the daily standard deviation (SDEV) for RET two years before (t= -1,-2) and two years after (t= +1,+2) surrounding each date recorded, or each observation.
So the column called BEFORE, the average daily standard deviation across the years (–1,–2) is calculated for all observations.
And the column called AFTER. This is an average daily standard deviation across the years (+1, +2) is also calculated for all observations.
-I then subtract BEFORE-AFTER, to produce a difference column (DIFF) which should be produced for all the observations.
Is this possible to see in code?
That is more easy. Remove the case clause in SQL.
proc sql; create table temp as select h.*, (select std(ret) from test_vol where permno = h.permno and date between intnx('year',h.date,-1,'s') and h.date) as std_one_year_before , (select std(ret) from test_vol where permno = h.permno and date between intnx('year',h.date,-2,'s') and h.date) as std_two_year_before , (select std(ret) from test_vol where permno = h.permno and date between h.date and intnx('year',h.date,1,'s')) as std_one_year_after , (select std(ret) from test_vol where permno = h.permno and date between h.date and intnx('year',h.date,2,'s')) as std_two_year_after from test_vol as h;quit;
Ksharp
Message was edited by: xia keshan
Thank you very much. I find that this code takes a while to run on my SAS, just checking, is it the same for you?
Yes. I also need some time to run . maybe your data is a little big .
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.