Base SAS 8

The following SAS program is submitted:
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?
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.
Click Comment link to get answer

9 comments:

  1. Answer is B.
    data monthly (keep = sales);
    do i = 1 to 60;
    sales = i*10;
    output;
    end;
    run;
    data work.totalsales(keep = msales{12} ) ;
    set work.monthly (keep = sales);
    array msales {12} ;
    do i=1 to 12;
    msales{i} = sales;
    end;
    run;

    log file:
    153 data work.totalsales(keep = msales{12} ) ;
    -
    214
    23
    ERROR 214-322: Variable name { is not valid.

    ERROR 23-7: Invalid value for the KEEP option.

    --
    23
    -
    23
    153! data work.totalsales(keep = msales{12} ) ;
    --
    214
    ERROR 214-322: Variable name 12 is not valid.

    153! data work.totalsales(keep = msales{12} ) ;
    -
    214
    ERROR 214-322: Variable name } is not valid.

    Program will run without errors if we change keep = statement as
    data work.totalsales(keep = msales1-msales12 ) ;
    set work.monthly (keep = sales);
    array msales {12} ;
    do i=1 to 12;
    msales{i} = sales;
    end;
    run;

    ReplyDelete
  2. syntax error - coz there is no variable as monthsale{12}...the variable is monthsale12

    ReplyDelete
  3. the answer might be Invalid value for the KEEP option.

    ReplyDelete
  4. correct answer B

    ReplyDelete
  5. yap B is correct one bez it is d syntax error

    ReplyDelete
  6. ans is B as there is error in the first data step. no proper execution

    ReplyDelete