DATA Step, Macro, Functions and more

End of month

Reply
Contributor oht
Contributor
Posts: 25

End of month

Hi ,

I need to calculate in the end of the month day (e.i. 30,31,28,29) . Does anybody has any idea ?

Thanks

Super Contributor
Posts: 282

Re: End of month

Hi,

Does the following help:

http://support.sas.com/kb/31/443.html

Regards,

Amir.

Contributor oht
Contributor
Posts: 25

Re: End of month

That's what I am looking for. Thanks for your help !!

PROC Star
Posts: 7,363

Re: End of month

You didn't indicate anything about your data.  If they are just date fields and you want to know how many days were in the month represented by the dates you could use something like:

data have;

  input havedate date9.;

  format havedate date9.;

  days_in_month=day(intnx('month',havedate,0,'e'));

  cards;

03OCT2012

;

Super Contributor
Posts: 1,636

Re: End of month

Exactly the same:

data have;

  input date mmddyy10.;

  format date mmddyy10.;

  cards;

  01/23/2012

  02/04/2012

  09/21/2012

  ;

  data want;

    set have;

day_at_end_of_month=day(intnx('month',date,0,'e'));

proc print;run;

Ask a Question
Discussion stats
  • 4 replies
  • 208 views
  • 0 likes
  • 4 in conversation