I am trying to get a list of the last day of each month for the last 6 months from a specific date.
Here is my code and it produces a blank for the first row and I'm not sure why.
data DateList; enddate= '30Sep2021'd; do i = -1 to -5 by -1; output; date=intnx('month',enddate,i,'e'); end; keep date; format date DDMMYY10.; run;
Any help and explanation would be greatly appreciated.
Thanks
Since you don't assign any value to DATE (the only variable you are keeping) before you write the observation how could ever be anything other than missing?
data DateList;
enddate= '30Sep2021'd;
do i = -1 to -5 by -1;
date=intnx('month',enddate,i,'e');
output;
end;
keep date;
format date DDMMYY10.;
run;
PS Why would you display dates in a style that will confuse 50% of the world?
Thank you Tom, that has solved my question and feel slightly silly now.
I'm in the UK and we ready dates in this format so helps me whilst coding to see dates in this format to check the code is working appropriately.
Thank you again for your help!
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.