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!
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;
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;
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!
just change the format from date9. to yymmddn8.
Hi Art,
yymmdd8. doesn't work for me. I changed it to yymmddn8. to get 20080828. Thank you!
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.
Hope they will win the game. I know you graduated there.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.