SAS Base Programming for SAS 9 — Question 18
A raw data record is listed below:
--------10-------20-------30
1999/10/25
The following SAS program is submitted:
data projectduration;
infile 'file-specification';
input date $ 1 - 10;
run;
Which one of the following statements completes the program above and computes the duration of the project in days as of today's date?
Answer options
- A. duration = today( ) - put(date,ddmmyy10.);
- B. duration = today( ) - put(date,yymmdd10.);
- C. duration = today( ) - input(date,ddmmyy10.);
- D. duration = today( ) - input(date,yymmdd10.);
Correct answer: D
Explanation
The correct answer is D because it uses the input function with the yymmdd10. format to convert the date string into a SAS date value, allowing for accurate calculation of the duration in days. Options A and B incorrectly use the put function, which converts the date into a character string instead of a numeric SAS date, while option C uses the ddmmyy10. format, which does not match the format of the provided date.