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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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