SAS Base Certification Practice – Question 7

Question 7: The following SAS program is submitted:
 

1
2
3
4
5
6
7
data work.totalsales (keep = monthsales{12} );
set work.monthlysales (keep = year product sales);
array monthsales {12} ;
do i=1 to 12;
monthsales{i} = sales;
end;
run;

The data set named WORK.MONTHLYSALES has one observation per month for each of five years for a total of 60 observations.

Which one of the following is the result of the above program?

Options:

A. The program fails execution due to data errors.
B. The program fails execution due to syntax errors.
C. The program executes with warnings and creates the WORK.TOTALSALES data set.
D. The program executes without errors or warnings and creates the WORK.TOTALSALES data set.

*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

4 Comments

    Suseela Sep 21, 2014

    Could you explain me this a little more.

    Reply
      igor Mar 23, 2015

      You are not allowed to use arrays in keep= drop= length, label

      Reply
    hydroweaver Jun 09, 2015

    If the SET data set is only keeping certain variables, then the output data set cannot drop or keep any other variable, so if this was not a syntax error, it would have still given a WARNING since monthlysales is only retaining YEAR, PRODUCT & SALES.

    Reply
    Maksim Jun 12, 2015

    There is a better solution than DROP. KEEP still can be used with next syntax:
    data work.totalsales (keep = monthsales1-monthsales12);

    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.