BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kt_uwa1990
Calcite | Level 5

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

Ksharp
Super User

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?

kt_uwa1990
Calcite | Level 5

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?

Ksharp
Super User

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

kt_uwa1990
Calcite | Level 5

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?

Ksharp
Super User

Yes. I also need some time to run . maybe your data is a little big .

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 20 replies
  • 1547 views
  • 6 likes
  • 4 in conversation