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!!
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
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;
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.