SAS Base (57)

Given the SAS data set WORK.ONE:

N BeginDate
1 09JAN201
2 12JAN201

The following SAS program is submitted:

data WORK.TWO;
set WORK.ONE;
Day=<_insert_code_>;
format BeginDate date9.;
run;

The data set WORK.TWO is created, where Day would be 1 for Sunday, 2 for Monday, 3 for Tuesday, … :

N BeginDate Day
1 09JAN2010 7
2 12JAN2010 3

Which expression successfully completed the program and creates the variable Day?

A. day(BeginDate)
B. weekday(BeginDate)
C. dayofweek(BeginDate)
D. getday(BeginDate,today())

Check Answer
Answer: B

注解:WEEKDAY function  returns an integer that corresponds to the day of the week, where 1=Sunday, 2=Monday, …, 7=Saturday, from a SAS date value. DAY function returns the day of the month. There is no function called DAYOFWEEK or GETDAY in SAS.