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;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: