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.
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.