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