ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 74

The following SAS program is submitted:
data stats;
set revenue;
array weekly{5} mon tue wed thu fri;

total = weekly{i} * .25;
output;
end;
run;
Which one of the following DO statements completes the program and processes the elements of the WEEKLY array?
A. do i = 1 to 5;
B. do weekly{i} = 1 to 5;
C. do i = mon tue wed thu fri;
D. A DO loop cannot be used because the variables referenced do not end in a digit.
Click Comment link to get answer

11 comments:

  1. Anonymous2:02 AM

    A is the correct ans

    ReplyDelete
  2. Anonymous3:32 AM

    A is correct answer

    ReplyDelete
  3. Anonymous1:08 PM

    Was able to get 'A' to execute, 'B' caused a syntax error...does anyone have a better explanation though? Thanks.

    ReplyDelete
  4. Anonymous5:31 PM

    What explanation do you need? A is the way to do it and B is a syntax error!

    ReplyDelete
  5. Anonymous11:58 AM

    It is because you need a do loop to go through it 5 times for the 5 days and call the do lpool 'i'. This can then be referenced later on in 'total = weekly{i} * .25;'

    ReplyDelete
  6. Anonymous11:43 PM

    Haven't seen a good explanation here. Seems like a, b, or c should work.
    Is it because we need to do arithmetic?

    ReplyDelete
    Replies
    1. Anonymous5:49 PM

      mon tue wed thu fri are variables' name, are not id numbers so answer "C.do i = mon tue wed thu fri;" is not correct. These 5 variables are grouped in by weekly, we can use weekly{1} which is same as mon, and ditto to other 4 variables.

      If you like, you can try the following code to understand them better:

      data revenue;
      input mon tue wed thu fri;
      datalines;
      1 1.1 1.2 1.3 1.4
      2 2.1 2.2 2.3 2.4
      ;
      run;


      data stats;
      set revenue;
      array weekly{5} mon tue wed thu fri;
      do i = 1 to 5;
      total = weekly{i} * .25;
      put weekly{i}= total=;
      output;
      end;
      run;

      Delete
    2. Anonymous7:08 AM

      u r awesome

      Delete