I want to create a time series field between two dates such that there is only one entry for each month and the day in that entry is the last day of that specific month.
For ex:-
Input:-
Start Date = 01/01/18 End Date = 31/12/20
Output:-
31/01/18
28/02/18
31/03/18
30/04/18
.
.
.
.
.
.
31/10/20
30/11/20
31/12/20
Use the intnx() function to calculate your end-of-period values:
cur_date = intnx('month',start_date,0,'e');
do while (cur_date le end_date);
output;
cur_date = intnx('month',cur_date,1,'e');
end;
It is, of course, assumed that start_date and end_date contain SAS date values.
Use the intnx() function to calculate your end-of-period values:
cur_date = intnx('month',start_date,0,'e');
do while (cur_date le end_date);
output;
cur_date = intnx('month',cur_date,1,'e');
end;
It is, of course, assumed that start_date and end_date contain SAS date values.
options yearcutoff=2000;
%let indate=01/01/18;
%let outmon=12/18;
data toto;
sdate=input("&indate",ddmmyy8.);
emon=input("01/&outmon",ddmmyy8.);
edate=intnx ('month',emon,0,'E');
days=edate-sdate;
do i=0 to days;
datest=sdate+i;
output;
end;
format datest ddmmyy8.;
keep datest;
run;
Hi,
it is not optimal but it works
have a nice day.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.