By admin | August 21, 2009

SAS Certified Adv Programmer 50 Questions (42)

The SAS data set One consists of five million observations and has 25 variables. Which one of the following SAS programs requires the least CPU time to be processed?

a.

data two;
    set one;
    if year(date)=1999 and state in
        ('NY' 'NJ' 'CT') then
        sales=sales98*1.1;
    else if year(date)=2000 and state in
        ('NY' 'NJ' 'CT') then
        sales=sales98*1.15;
    else if year(date)=2001 and state in
        ('NY' 'NJ' 'CT') then
        sales=sales98*1.2;
run;

b.

data two;
    set one;
    if year(date)=1999 and state in
        ('NY' 'NJ' 'CT') then
        sales=sales98*1.1;
    if year(date)=2000 and state in
        ('NY' 'NJ' 'CT') then
        sales=sales98*1.15;
    if year(date)=2001 and state in
        ('NY' 'NJ' 'CT') then
        sales=sales98*1.2;
run;

c.

data two;
    set one;
    if state in ('NY' 'NJ' 'CT')then do;
        year=year(date);
    if year=1999 and state in('NY' 'NJ' 'CT') then
        sales=sales98*1.1;
    if year=2000 and state in('NY' 'NJ' 'CT') then
        sales=sales98*1.15;
    if year=2001 and state in('NY' 'NJ' 'CT') then
        sales=sales98*1.2
    end;
run;

d.

data two;
    set one;
    if state in('NY' 'NJ' 'CT') then do;
        year=year(date);
        select(year);
            when(1999) sales=sales98*1.1;
            when(2000) sales=sales98*1.15;
            when(2001) sales=sales98*1.2;
            otherwise;
        end;
    end;
run;

One comment | Add One

  1. admin - 08/21/2009 at 1:13 pm

    D

Leave a Comment

Leave a Reply

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