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

Thank you very much for all. I will run the codes and let you know.

Abu Chowdhury

AbuChowdhury
Fluorite | Level 6

Hi,

I submitted your proc sql codes but it's taking very long time. For example, it takes more than two hours to calculate the CAR for different windows (such as (0,65) days, (66,130) days etc.)  when the dataset has 2502 event days (tradedate). I have another dataset where there are approximately 35,000 event days, and it took more than 40 hours to get the CARs ! Is it normal for taking such long time or is there something wrong?

In the attached file, I calculated the CARs for different windows using your codes. For each firm (the variable 'Code' ) I need to have only one CAR for each year. For example, if the same firm has multiple CARs in a specific year because of the multiple tradedates, the average (or sum) of those CARs for that year needs to be calculated. It means, for each firm for each year there should be one CAR value. How can I do that?

Abu Chowdhury

Ksharp
Super User

You can make three index for code, date , tradedate  respectively . Maybe That would fast you.

And about more fast way, what I could think is using Hash Table , But that is a long story to tell.

Xia Keshan

AbuChowdhury
Fluorite | Level 6

Thanks but I did not understand how to make index. I will be grateful if you tell me.

I had the second query:

In the attached file, I calculated the CARs for different windows using your codes. For each firm (the variable 'Code' ) I need to have only one CAR for each year. For example, if the same firm has multiple CARs in a specific year because of the multiple tradedates, the average (or sum) of those CARs for that year needs to be calculated. It means, for each firm for each year there should be one CAR value. How can I do that?

Waiting for your reply.

Ksharp
Super User
data class;
 set sashelp.class;
run;
proc datasets library=work;
 modify class;
  index create age;
quit;

Start a new topic, and let others knows your problem, I can't get you .

Xia Keshan

AbuChowdhury
Fluorite | Level 6

Hi,

Something is going wrong. If you remember, you gave me the following proc sql for calculating cumulative abnormal returns.

proc sql;

create table want as

  select a.*,(select sum(value) from x where code=a.code and date between tradedate and tradedate+65) as _65

   from trading_obs as a;

quit;

However, I ran this for 3 days ( ..... tradedate and tradedate+3) and manually checked the results. Surprisingly, it shows correct car in some event days but in many cases it shows wrong cars for respective event days (tradedate). What's the reason for that? I gave you the two datasets previously; please check and let me know.

AbuChowdhury
Fluorite | Level 6

I think the reason is as follows. When I wanted to calculate the CAR for (0,65) days window, I wanted to calculate actually for (0,3) months window. Since the dataset has approximately 260 observations per year (because, no data for weekends and holidays), so 3 months mean approximately 65 observations per year. But, according to calendar days, there are approximately 91 days in a 3-month period. Your sql proc chooses the calendar days. So in your proc sql when you wrote (…..between tradedate and tradedate+65), it took the 65 calendar days. So, since I want a 3-month window, I should write:

…… between tradedate and tradedate+91

Please let me know whether I am correct or not.

Ksharp
Super User

Yes. You are right. I am counting Calendar days.

About your only one CAR for every year and every company . you can do this:

After you get CAR for every obs , you can do this:

select .........,avg(_65) as one_avg

from want

  group by code,year ;

Xia Keshan

AbuChowdhury
Fluorite | Level 6

Thanks a lot.

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 23 replies
  • 7644 views
  • 6 likes
  • 3 in conversation