SAS Base Certification Practice – Question 10

Question 10: The contents of the raw data file CALENDAR are listed below:
 

--------10-------20-------30
01012000

The following SAS program is submitted:

1
2
3
4
5
data test;
infile 'calendar';
input @1 date mmddyy10.;
if date = '01012000'd then event = 'January 1st';
run;

Which one of the following is the value of the EVENT variable?

Options:

A. 01012000
B. January 1st
C. . (missing numeric value)
D. The value cannot be determined as the program fails to execute due to errors.

*This blog is not affiliated with SAS or the SAS Institute. All answer logs, data sets, output, and commentary are provided by this blog.

Correct Answer

Incorrect Answer

Click to see Answer Explanation below

thanks for your support

9 Comments

    Keith Apr 20, 2015

    I could be wrong but it says d is the correct answer but where could one possibly know that information from? Isn’t the correct answers b? the sas date value is the issue I believe

    Reply
    Naoyo Nov 13, 2015

    Hi Keith,

    mmddyy10 is error. I think it should be mmddyy8 since date is 01012000.

    Reply
    Venkatesh Dec 23, 2015

    Correct Answer is D only, as the ‘DATE CONSTANT’ functions can be verified on DATEX. format not DDMMYYX. format.

    Reply
    mbvenkat Dec 31, 2015

    Correct answer is D only, as SAS allows to check the date constant value with format ‘DATE7, DATE5, DATE9’ only .

    Date constant check is invalid with format of MMDDYYYY.

    Reply
    Rajesh Dabral Aug 20, 2016

    if date = ’01JAN2000’d will work fine.

    Reply
    Rockeps Aug 24, 2016

    Question: If this was a multi step or muti provv problem, would it continue to try to execute other steps? Or once a Data or prov step fails does entire program file ?

    Reply
    Rockeps Aug 24, 2016

    Sorry…. multi step or PROC

    Reply
    epiphaniesarefun Aug 28, 2016

    The correct answer is:
    data test;

    input @1 date mmddyy8.;
    if date eq ’01JAN2000’d then event = ‘January 1st’;
    datalines;
    01012000
    ;

    run;

    The if statement was in the wrong place and the literal was in the wrong format.

    Reply
    toan Oct 05, 2016

    So are there TWO syntax errors? The date format of MMDDYY10. should be MMDDYY8. AND the if date= ‘01012000’d is incorrect and should be ddmmmyy/ddmmmyyyy?

    Reply

Leave a Comment

Please keep in mind that comments are moderated and rel="nofollow" is in use. So, please do not use a spammy keyword or a domain as your name, or it will be deleted. Let us have a personal and meaningful conversation instead.