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!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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