Hi,
I have two datasets. One has only yearly observations for month 7. Another one has monthly frequency for each year year.
I need to rearrange this code for the dataset where with monthly observations and find a monthly holding period of 30 days. My monthly dataset starts in january 1926 and ends in march 2012.
This is the code for the dataset for annual observations
/*I'm creating two variables. These are date variables.
one will store July 1st of the same year
one will store 30/ of next year
this is the holding period.
This is useful because I only need to get from CRSP the return for this period*/
data sample_stocks;
set sample5;
Beginning_date=mdy(07,01,year);
End_date=mdy(06,30,year+1);
format End_date date9.;
format Beginning_date date9.;
drop Mkcap sum_Mkcap number_stocks;
run;
Do you have any tips to modify this code?
If all you want is the end date from the next month:
end_date = intnx("month", date, 1, "end");
Please provide a small meaningful sample of both input datasets and of the corresponding expected output data table.
This is a sample of my input table:
This is what i would like have in output:
The Beginning_year should be equal to my date, because it represent the start point of the my Holding period.
The End_Date should be equal to the last day of the next month (ex. in the first row should be equal to 28FEB1926), because my holding period is one month.
I hope this suggestions, will be clear.
Thanks for your help.
If all you want is the end date from the next month:
end_date = intnx("month", date, 1, "end");
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 25. 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.