ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 63

The SAS data set named WORK.TEST is listed below:
capacity airplanetype staff
150 Large 10
Which one of the following SAS programs created this data set?
A. data work.test;
capacity = 150;
if 100 le capacity le 200 then
airplanetype = 'Large' and staff = 10;
else airplanetype = 'Small' and staff = 5;
run;
B. data work.test;
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
end;
else
do;
airplanetype = 'Small';
staff = 5;
end;
run;
C. data work.test;
capacity = 150;
if 100 le capacity le 200 then
do;
airplanetype = 'Large';
staff = 10;
else
do;
airplanetype = 'Small';
staff = 5;
end;
run;
D. data work.test;
capacity = 150;
if 100 le capacity le 200 then;
airplanetype = 'Small';
staff = 5;
else;
airplanetype = 'Large';
staff = 10;
run;
Click Comment link to get answer

26 comments:

  1. Anonymous5:13 AM

    what about A?

    ReplyDelete
    Replies
    1. if ....and.....then....
      we cannot do:
      if ....then ....and...

      ("and" is basically used to connect two clauses)

      Delete
    2. B is the correct answer.

      Delete
  2. Anonymous4:47 PM

    if a then b and c;
    It seems that only b will be carried out.

    ReplyDelete
  3. Anonymous10:53 AM

    Defintely B

    ReplyDelete
  4. In A you have tis line in error
    airplanetype = 'Large' and staff = 10;

    In C you have a Structure Problem

    and In D the condition is reverse

    So the answer is B

    ReplyDelete
  5. Anonymous2:46 PM

    could u pls explain why the error is occuring in A

    ReplyDelete
  6. See highligted are the mistakes and B choice has no errors so it is the correct choice.

    A. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then
    airplanetype = 'Large' and staff = 10;
    else airplanetype = 'Small' and staff = 5;
    run;
    B. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then
    do;
    airplanetype = 'Large';
    staff = 10;
    end;
    else
    do;
    airplanetype = 'Small';
    staff = 5;
    end;
    run;
    C. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then
    do;
    airplanetype = 'Large';
    staff = 10;
    else /*end missing for if do loop*/
    do;
    airplanetype = 'Small';
    staff = 5;
    end;
    run;
    D. data work.test;
    capacity = 150;
    if 100 le capacity le 200 then;
    airplanetype = 'Small';
    staff = 5;
    else; /* there is no if associated with this else */
    airplanetype = 'Large';
    staff = 10;
    run;

    ReplyDelete
    Replies
    1. Good explanation vikas
      thanks

      Delete
    2. Thanks! very helpful

      Delete
  7. Anonymous1:52 AM

    Answer is B

    reason:
    If we would perform more than one action under an if statement, we should use do-end loop whithin.

    ReplyDelete
  8. Anonymous6:14 PM

    Understand that correct answer is B by POE, thank you. However, could someone explain why A gives this output:

    capacity airplanetype staff
    150 0 .

    ReplyDelete
  9. Anonymous2:52 PM

    I think each do loops needed an END statement c - is not a correct answer.
    A : "and" does not execute it?

    ReplyDelete
  10. Anonymous5:59 PM

    Guys;
    You will not sas program to run in Exam, some one said right, use your head and do the elimination process and choose one is correct then put it in program and conform your logic.

    We want to hear and share the logic not only the right answer, we can do that too.
    Am I right?

    ReplyDelete
  11. Anonymous6:05 PM

    Folks, in A. airplane = 'Large' and staff = 10 is the culprit.
    Both statement has to be satisfied together therefore answer B has separated and in two statement and that is the one we are going to choose.
    Peace .

    ReplyDelete
  12. Anonymous6:10 PM

    Guddu;
    In exam you are not going to run this program and get the right answer.
    We can run and get the answer too.
    Give us the right logic behind it and we are not trying to memories it. What if they do little change on the same question but we have to choose the different answer.

    ReplyDelete
  13. Anonymous5:40 AM

    woudl A work if it had ()?

    data work.test;
    capacity = 150;
    if 100 le capacity le 200 then
    (airplanetype = 'Large' and staff = 10);
    else (airplanetype = 'Small' and staff = 5);
    run;

    Thx in advance.

    ReplyDelete
    Replies
    1. your code is correct, i run it in SAS

      Delete
  14. Anonymous6:01 AM

    within if loop we can assign only one task. therefore if we want more than one task either calculation/creating variable/assigning value we use DO-END loop. hence answer is b

    ReplyDelete
    Replies
    1. Anonymous1:55 PM

      Finally. Thank you.

      Delete
    2. Any time you have more than 1 things to do , then use do loop and need to end with end ; that is why b is option; C also looks same but is not the right ans becoz missing end in do loop. A is not ans as it is missing do loop.

      Delete
  15. Anonymous8:36 AM

    Is there something comparable to this blog for advanced certification preparation?

    ReplyDelete

  16. This Is Really Useful And Nice Information. ราคาบอล
    This are such great articles. ราคาบอล This articles can help you to make some new ideas.
    https://sakukrub98.hatenablog.com/entry/2020/08/19/121317?_ga=2.74836054.594202270.1597630955-1286484823.1596077192 I appreciate for reading my blogs.


    ReplyDelete