01-04-2013 10:10 AM
Date A = 31Dec2012
Date B = 12Dec2012
Then I want to know which nth Weekday Date A is since Date B
In this example Date A would be the 3rd Monday since Date B.
Is there anyway to calculate this automatically? Output like 3-2 (3rd-Monday)
01-04-2013 10:55 AM
You may be able to accomplish this using a combination of INTCK which returns intervals between SAS date values such as weeks, and the WEEKDAY function which will return day of the week of a SAS date value. Check the online help for syntax, intervals supported and starts (not everyone considers the week to start on the same day).
01-04-2013 11:04 AM
Check out the below code and see if it works for you.
length output $10;
date_a = '31Dec2012'd;
date_b = '12Dec2012'd;
weeka = week(date_a,'u');
weekdaya = weekday(date_a);
weekb = week(date_b,'u');
output = strip(put(weeka-weekb,best.))||'-'||strip(put(weekdaya,best.));
format date_a date_b date9.;
Need further help from the community? Please ask a new question.