- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sql;
select HAVE.FRIMID, COMP_T, CRSP_T, ASSET, RETURN
from HAVE, CRSP
where HAVE.date =CRSP.(date+1year or +1month) and HAVE.ID =CRSP.ID
quit;
This code just represents what I want...
you can see
HAVE.date =CRSP.(date+1year)
What I am doing now is to calculate annual return starting from a specific date. e.g. 2019/10/31~2020/10/31. To do this, I need to have prices now and a year later. However, I do not know how to match. Since it is not just a number but year... +1 does not work.
Please help me how can I add day/month/year on my identifiers when they are calendar dates...
I first made code to transform that YYMMDD to YYMM and then +1. but it sometimes does not make sense as if the case is 2013/12 then +1 is 2013/13... or 2013/10/31 became 2013/10/32... instead 2013/11/01.
Because I need to match same to same+@ instead same to same, I am struggling with this.
Please help me. I searched for other posts but haven't found similar.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So SAS has a function INTNX() that allows you increment dates instead. However, to use it you must have a SAS date, which is a numeric variable (variable type) with a date format applied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use the intnx() function to calculate date intervals.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So SAS has a function INTNX() that allows you increment dates instead. However, to use it you must have a SAS date, which is a numeric variable (variable type) with a date format applied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am pretty sure how intnx or intck.
Before doing my works, I just want to ask a quick question. INTNX() just increments dates, months, or years but does not check whether these incremented dates are trading days or not. If so, I need to add another code to match my data properly and more precisely by like this..
having (b.trading-a.non_trading)=min(b.trading-a.non_trading);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content