SAS Base Certification – Practice Exam 6

Question 6: The following SAS program is submitted:

1
2
3
4
5
data class;
   set sashelp.class(keep=name age height weight);
   drop=age;
   newage=age+1;
run;

The data set Sashelp.Class contains 5 variables. What is the result?

Options:

a.	0 variables are written because there is a syntax error.   
b.	4 variables are written to the data set Work.class. 
c.	5 variables are written to the data set Work.class.  
d.	6 variables are written to the data set Work.class. 

*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

7 Comments

    Vishesh Oct 06, 2015

    Wrong, the correct answer is 5 variables. Age won’t appear in output dataset.

    Reply
    SaraF Oct 28, 2015

    shouldnt the answer be 4? the original keep statement says keep 4 variables, and since that is in the set statement, thats all that is kept. nothing can override that, right??

    Reply
    SaraF Oct 28, 2015

    I read where you are not supposed to use a keep and drop statements together. So, in the set statement, you only keep 4 variables. Lets assume that since a keep was used, drop is not a recognized function anymore. Thus, you still only keep 4 variables.

    Other idea: Lets assume the drop statement does in fact work like the function is supposed to. Set statement keeps 4 variables, then 1 of those variables are dropped. Thus, only leaving 3 variables.

    Reply
    SaraF Oct 29, 2015

    This is the log from a similar program that I ran to check this. Turns out, the answer is in fact 6 variables and drop is now a variable. Weird but here it is:

    1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
    55
    56 data class;
    57 set orion.discount(keep=product_id start_date end_date unit_sales_price);
    58 drop=start_date;
    59 newprice=unit_sales_price+1;
    60 run;

    NOTE: There were 697 observations read from the data set ORION.DISCOUNT.
    NOTE: The data set WORK.CLASS has 697 observations and 6 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.00 seconds
    cpu time 0.00 seconds

    61
    62 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
    74

    Reply
    ankans Jan 25, 2016

    Drop as statement cannot use ‘=’
    Here now it becomes a new variable which copies age in it. Therefore 6 variables

    Reply
    zheng Jun 22, 2017

    This question is so tricky. Since drop is not in the bracket following the set function. So tricky is created as a variable.name + age + height + weight + drop + newage. There’s total 6 vars

    Reply
      zheng Jun 22, 2017

      drop is created as a variable

      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.