By admin | September 29, 2009

SAS Certified Base Programmer 123 Questions (93)

The following SAS program is submitted:

proc sort data = sasuser.houses out = houses;
    by style;
run;

proc print data = houses;
    <insert statement(s) here>
run;

Click on the Exhibit button to view the report produced.

style     bedrooms baths price
CONDO     2        1.5   80050
          3        2.5   79350
          4        2.5   127150
          2        2.0   110700
RANCH     2        1.0   64000
          3        3.0   86650
          3        1.0   89100
          1        1.0   34550
SPLIT     1        1.0   65850
          4        3.0   94450
          3        1.5   73650
TWOSTORY  4        3.0   107250
          2        1.0   55850
          2        1.0   69250
          4        2.5   102950

Which of the following SAS statement(s) create(s) the report?

A.
id style;

B.
id style;
var style bedrooms baths price;

C.
id style;
var style bedrooms baths price;

D.
id style;
by style;
var style bedrooms baths price;

11 comments | Add One

  1. admin - 09/29/2009 at 3:55 pm

    C

  2. ferrat - 10/14/2009 at 6:49 am

    The answer should be:

    id style;
    by style;
    var bedrooms baths price;

    Reason:
    If a variable in the ID statement also appears in the VAR statement, the output contains two columns for that variable!

  3. JG - 07/28/2010 at 2:43 am

    D

  4. JG - 07/28/2010 at 2:45 am

    The C should be:
    id style;
    by style;
    var bedrooms baths price;

  5. susan - 08/19/2010 at 1:55 pm

    @2. ferrat I tested in SAS and I totally agree with you!!

  6. Chong Wang - 09/14/2010 at 11:14 pm

    I think C and D have same listing output because work.houses has been sorted.

  7. sudha - 12/19/2010 at 3:40 am

    c must be as below…..

    id style;
    by style;
    var bedrooms baths price;

  8. Panda - 01/29/2012 at 2:21 pm

    is there any obvious difference between choices B and C?

    if no difference I would like to go with either or them

  9. Huazi Zeng - 10/13/2012 at 4:45 am

    @6. I do not think so,because the data must be presorted by the BY variables when using By statement.

  10. Karen - 03/5/2013 at 5:51 pm

    The answer B and C are exactly the same. Typo? Please correct it. Thank you.

  11. hh - 02/24/2014 at 8:30 am

    I also tested in SAS. I agree with @2. ferrat.

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *