Thank you very much for all. I will run the codes and let you know.
Abu Chowdhury
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
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
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.
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
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.
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.
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
Thanks a lot.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: