HI!!!
I found a very close answer here:
But still... I wonder how can I get a monthly return from a specific date.
e.g. from July 13th to Aug 13.
If either or both dates are nontrading days, then select the next trading days. Since I have to have a month interval, the code used in the link that can only sets intervals instead of a certain period of time(like month and year) is not the right one.
I wonder how other CRSP users can get stock returns too.
If you use CRSP and know how to get month-long returns please share your knowledge.
Thank you,
The first part will be starting with actual SAS date values. Do you have that yet?
I think that you want the INTNX function with the 'Same' option.
data example;
do date='25Jan2020'd to '31JAN2020'd;
newdate = intnx('month',date,1,'S');
output;
end;
format date newdate date9.;
run;
I used dates from 2020 as it is a leap year. 29, 30 and 31 Jan all get advanced to 29 Feb.
If you use 2019 then 28, 29, 30 and 31 Jan all get advanced to 28 Feb.
The first part will be starting with actual SAS date values. Do you have that yet?
I think that you want the INTNX function with the 'Same' option.
data example;
do date='25Jan2020'd to '31JAN2020'd;
newdate = intnx('month',date,1,'S');
output;
end;
format date newdate date9.;
run;
I used dates from 2020 as it is a leap year. 29, 30 and 31 Jan all get advanced to 29 Feb.
If you use 2019 then 28, 29, 30 and 31 Jan all get advanced to 28 Feb.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.