BookmarkSubscribeRSS Feed
mvk_sas
Calcite | Level 5

Hi ,

I am a newbee to this community ,.. but i follow the question and answers posted here.

My question is there a way that we can calculate days in a given month EX: Jan =31 days Feb = 28 or 29.

Moreover i need to check given year is leap year or normail year then need to calculate number of days in each month.

Any help appreciated!!

2 REPLIES 2
Linlin
Lapis Lazuli | Level 10

Hi,

You can use the code below to calculate the number of day in 2011:

data want;

do month=1 to 11;

days=mdy(month+1,1,2011)-mdy(month,1,2011);

output;

end;

month=12;

days=mdy(1,1,2012)-mdy(12,1,2011);

output;

proc print;run;

                                        Obs    month    days

                                         1       1      31

                                         2       2      28

                                         3       3      31

                                         4       4      30

                                         5       5      31

                                         6       6      30

                                         7       7      31

                                         8       8      31

                                         9       9      30

                                        10      10      31

                                        11      11      30

                                        12      12      31

Linlin

polingjw
Quartz | Level 8

data dates;

input month $;

start = input(month, anydtdte.);

num_days = day(intnx('MONTH', start, 0, 'END'));

put (month num_days) (=);

datalines;

Jan11

Apr11

Feb11

Feb12

;

run;

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, 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
  • 2 replies
  • 795 views
  • 6 likes
  • 3 in conversation