BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Benn
Calcite | Level 5

Hi Guys,

I'm trying to retrieve from my data the last day (not calender day) of each month. However the last day may not be the last day of the calender month, but the last day of the month given my data.

Eg. 20080601

      20080627

      20080622

      20080712

      20080729

      20100128

      20100125

I am trying to get a code to retrieve 20080627, 20080729 and 20109128.

Thanks a lot guys!

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

You could do it easily with proc sql:

proc sql;

  create table want as

    select max(date) as last_day format date9.

      from have

        group by year(date),month(date)

  ;

quit;

View solution in original post

6 REPLIES 6
art297
Opal | Level 21

You could do it easily with proc sql:

proc sql;

  create table want as

    select max(date) as last_day format date9.

      from have

        group by year(date),month(date)

  ;

quit;

Benn
Calcite | Level 5

Hi Arthur,

Thanks for the code.

I was wondering if the date can be left in the original format YYYYMMDD. Because the code results in "2008 JAN 01" .

Thanks!

art297
Opal | Level 21

just change the format from date9. to yymmddn8.

Linlin
Lapis Lazuli | Level 10

Hi Art,

yymmdd8. doesn't work for me. I changed it to yymmddn8. to get 20080828.  Thank you!

art297
Opal | Level 21

Linlin: Then I will change mine as well.  As you can tell, it wasn't tested code.  Too busy listening to the Michigan State football game.

Linlin
Lapis Lazuli | Level 10

Hope they will win the game. I know you graduated there.Smiley Happy

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

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 6 replies
  • 3013 views
  • 0 likes
  • 3 in conversation