BookmarkSubscribeRSS Feed
RikeshPunja
Fluorite | Level 6

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

2 REPLIES 2
Tom
Super User Tom
Super User

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?

RikeshPunja
Fluorite | Level 6

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!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 656 views
  • 0 likes
  • 2 in conversation