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.
Use the intnx() function to calculate date intervals.
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.