SAS Base Certification Practice – Question 9

Question 9: The following SAS program is submitted:
 

1
2
3
4
5
6
data work.january;
set work.allmonths (keep = product month num_sold cost);
if month = 'jan' then output work.january;
sales = cost * num_sold;
keep = product sales;
run;

Which variables does the WORK.JANUARY data set contain?

Options:

A. PRODUCT and SALES only
B. PRODUCT, MONTH, NUM_SOLD and COST only
C. PRODUCT, SALES, MONTH, NUM_SOLD and COST only
D. An incomplete output data set is created due to syntax 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

10 Comments

    RockyC Jul 30, 2015

    “WARNING: The data set WORK.JANUARY may be incomplete. When this step was stopped there were 0 observations and 6 variables.”

    6 variables – does this mean that the answer should be:
    PRODUCT, KEEP, SALES, MONTH, NUM_SOLD and COST?

    Reply
      Rachael Nov 28, 2016

      Technically, yes. However, that’s because it hit an error and didn’t execute the code. So D is the most correct, but all of the variables are in the incomplete data set.

      Reply
    Trushna Jan 11, 2016

    Syntax error because of keep = product sales;

    Reply
      Linda Aug 23, 2016

      Would it have worked if keep = followed by vars in ( )?

      Reply
        toan Oct 05, 2016

        Isn’t Var statement primarily for Proc Means/Summary for table analysis or Proc Print for outputting specific variables?

        Reply
          kamkh Jan 17, 2017

          I think what Linda means by ‘vars’ is ‘variables’. In other words: keep = (product sales) – Would this work?

          Reply
    shovland Nov 29, 2016

    Why is keep = OK at line 2 and not at line 5?

    Reply
    maksimk Oct 05, 2017

    Sometimes I just hate how SAS syntax is different the same things.

    Reply
    Sara Oct 16, 2017

    The reason that there is an error is because this is an assignment statement, so SAS is expecting a value, whether that’s a constant, variable, or expression, to be attributed to a variable named “keep”. However the program has two variable names which is not a valid assignment value so there is an error message.

    Reply
    Akshaya Mar 20, 2018

    In line 2, keep= is used as an option. In line 5, keep is used as a statement. No need of equal sign for the keep statement.

    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.