NWKDOM Function
Returns the date for the nth occurrence of a weekday for the specified month and year.
| Categories: | Date and Time |
| CAS |
Syntax
Required Arguments
n
specifies the numeric week of the month that contains the specified day.
| Range | 1–5 |
| Tip | N=5 indicates that the specified day occurs in the last week of that month. Sometimes n=4 and n=5 produce the same results. |
weekday
specifies the number that corresponds to the day of the week.
| Range | 1–7 |
| Tip | Sunday is considered the first day of the week and has a weekday value of 1. |
month
specifies the number that corresponds to the month of the year.
| Range | 1–12 |
year
specifies a four-digit calendar year.
Details
Comparisons
UnivGrad=nwkdom(1, 7, 6, year);Examples
Example 1: Returning Date Values
data _null_;
/* Return the date of the third Monday in May 2012. */
a=nwkdom(3, 2, 5, 2012);
/* Return the date of the fourth Wednesday in November 2012. */
b=nwkdom(4, 4, 11, 2012);
/* Return the date of the fourth Saturday in November 2012. */
c=nwkdom(4, 7, 11, 2012);
/* Return the date of the first Sunday in January 2013. */
d=nwkdom(1, 1, 1, 2013);
/* Return the date of the second Tuesday in September 2012. */
e=nwkdom(2, 3, 9, 2012);
/* Return the date of the fifth Thursday in December 2012. */
f=nwkdom(5, 5, 12, 2012);
put a= weekdatx.;
put b= weekdatx.;
put c= weekdatx.;
put d= weekdatx.;
put e= weekdatx.;
put f= weekdatx.;
run;a=Monday, 21 May 2012 b=Wednesday, 28 November 2012 c=Saturday, 24 November 2012 d=Sunday, 6 January 2013 e=Tuesday, 11 September 2012 f=Thursday, 27 December 2012
Example 2: Returning the Date of the Last Monday in May
data _null_;
/* The last Monday in May. */
x=nwkdom(5, 2, 5, 2012);
put x date9.;
run;28MAY2012