ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 58

The following SAS program is submitted:
data work.company;
set work.dept1(keep = jobcode)
work.dept2(rename = (jcode = jobcode));
run;
Which one of the following is the result?
A. The variable JCODE is written to the output data set.
B. The variable JOBCODE is written to the output data set.
C. Neither variable JCODE nor JOBCODE is written to the output data set.
D. The program fails to execute due to errors.
Click Comment link to get answer

20 comments:

  1. Anonymous8:20 AM

    The answer must be B. The variable jcode in the second dataset is renamed as JOBCODE and since there is no BY variable specified, the datasets are simply appended one on top without any overwriting..!!!

    ReplyDelete
  2. Anonymous1:56 PM

    Answer is B

    ReplyDelete
  3. Anonymous2:37 AM

    answer is D . no semi-colon after set stmt.

    ReplyDelete
    Replies
    1. Anonymous10:48 PM

      There isn't supposed to be a semicolon there. This is a concatenation-style merge operation.

      Delete
  4. Anonymous3:34 PM

    great catch on the semi-colon missing in the SET statement (D).

    ReplyDelete
    Replies
    1. if semi-colon given in 2nd line then it is error option (D). Answer is (B) as set function is for 2 nd and 3 rd line and renamed properly.

      Delete
  5. Anonymous4:25 PM

    set statement extends upto it finds a semicolon. So D is NOT the answer. B is the answer.

    ReplyDelete
  6. Yaah..Ans is B.
    If there is semicolon after set statement then the answer would be D.

    ReplyDelete
  7. Anonymous1:06 PM

    there IS a semicolon after the set stmt. in this case the set statement is taking 2 lines. answer is B.

    ReplyDelete
  8. Remya1:00 PM

    Answer is B.

    The code above can be rewritten in a way that set and the two datasets are in the same line. So the set statement continues till the end of work.dept2(rename = (jcode = jobcode));

    Since there is a semicolon that the end of the set statement, that is not an issue.

    Renaming the dataset takes place during the set statement, therefore the name is current. So both datasets have jobcode variable.

    "The RENAME= data set option in the SET statement renames variables in the input data set. You can use the new names in programming statements for the current DATA step. " - SAS H And D

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Anonymous9:39 PM

      Your detailed comments in response to most of the questions have been helpful. Thanks!

      Delete
  9. Anonymous2:51 AM

    there shud be a BY variable after a set statement ..right?

    ReplyDelete
    Replies
    1. By var after set stmt is not required as it can be either concatentaion or interleaving . Here is is concatentaion so no by var is required. ans is B

      Delete
  10. Ans is B

    ReplyDelete
  11. Anonymous9:15 PM

    B
    The variable jcode in the second dataset is renamed as JOBCODE

    ReplyDelete
  12. It is amazing that you have finally reached this point. i think that you had to overcome many obstacles that require the good physical availability.

    ReplyDelete