proc summary data=crspsdc1 nway;
where intck("day",Date, filing_Date) between -1 and 2;
class cusip filing_Date;
var price;
output out=want std=priceStd;
run;
Hi all!!
the above code is for having ranges and calculating std of the price. The code is good but I need sth more, obtaining business days only. Since filing dates are random and I need the range from filing data-1 to filing date+2, either or both filing data-1 and filing date+2 can be non-business days, which turns different _FREQ_ in the outcome from the code. The variable DATE only contains biz days so the code above could not count non-biz days and resulted in different FREQs in the WANT file...
So, I have been thinking the code finding closest business days from DATE variables. (DATE variables only contains biz days)
I know like having (a.XX - b.XX) = min (a.XX - b.XX) but this doesn't look working this case (this is useful for matching only) and have no idea how to create the BUSINESS DAY ONLY RANGE...
It seems that there is a widely-used code for this business day only interval as I can see this a lot when I read finance and accounting papers but hard to make the code...
I appreciate any of your comment!
Honestly, this is a non-trivial task, part of why SAS doesn't have an automatic function to do it and why there isn't a full/clear solution that someone will code up for you quickly - it's not a quick process and it does take some testing and time to get it working correctly. The benefit of creating a custom calendar, as noted in the threads, is the ability to use INTNX or INTCK() functions which make the remaining steps simpler.
This post is probably the best one to use as a starting point for your actual work, but I highly recommend the other threads first to understand some of the complexity of this problem.
@JKCho wrote:
Hi Reeza,
Yes. I know the WEEKDAY statement and now have trading dates only data(That is my DATE variable). As you mentioned WEEKDAY does not count other nontrading days, I am thinking of a new coding that can solve the question. What I struggle on is how to range these trading dates with the filing_date thee...
I already deleted the Canadian data for the ease of analysis.
Hi Reeza,
Yes. I know the WEEKDAY statement and now have trading dates only data(That is my DATE variable). As you mentioned WEEKDAY does not count other nontrading days, I am thinking of a new coding that can solve the question. What I struggle on is how to range these trading dates with the filing_date thee...
I already deleted the Canadian data for the ease of analysis.
Honestly, this is a non-trivial task, part of why SAS doesn't have an automatic function to do it and why there isn't a full/clear solution that someone will code up for you quickly - it's not a quick process and it does take some testing and time to get it working correctly. The benefit of creating a custom calendar, as noted in the threads, is the ability to use INTNX or INTCK() functions which make the remaining steps simpler.
This post is probably the best one to use as a starting point for your actual work, but I highly recommend the other threads first to understand some of the complexity of this problem.
@JKCho wrote:
Hi Reeza,
Yes. I know the WEEKDAY statement and now have trading dates only data(That is my DATE variable). As you mentioned WEEKDAY does not count other nontrading days, I am thinking of a new coding that can solve the question. What I struggle on is how to range these trading dates with the filing_date thee...
I already deleted the Canadian data for the ease of analysis.
Will you always have data for those windows?
If you can just take the records nearby based on record numbers rather than dates this is a much simpler problem to handle.
ie if your range (Date +/- 3 days) will have data for each of the 3 days on either side and not be missing data you can use that feature.
the above code is for having ranges and calculating std of the price. The code is good but I need sth more, obtaining business days only. Since filing dates are random and I need the range from filing data-1 to filing date+2, either or both filing data-1 and filing date+2 can be non-business days, which turns different _FREQ_ in the outcome from the code. The variable DATE only contains biz days so the code above could not count non-biz days and resulted in different FREQs in the WANT file...
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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: