ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 57

Which one of the following SAS statements renames two variables?
A. set work.dept1
work.dept2(rename = (jcode = jobcode)
(sal = salary));
B. set work.dept1
work.dept2(rename = (jcode = jobcode
sal = salary));
C. set work.dept1
work.dept2(rename = jcode = jobcode
sal = salary);
D. set work.dept1
work.dept2(rename = (jcode jobcode)
(sal salary));
Click Comment link to get answer

26 comments:

  1. Anonymous3:18 PM

    Could someone explain why is not A?

    ReplyDelete
    Replies
    1. These examples show the correct syntax for renaming variables using the RENAME statement:
      rename street=address;
      rename time1=temp1 time2=temp2 time3=temp3;
      rename name=Firstname
      score1-score3=Newscore1-Newscore3;

      Delete
  2. Anonymous9:07 PM

    because A is wrong

    ReplyDelete
  3. Anonymous2:10 PM

    data groceries;
    input item $ cost;
    retain grandtot 0;
    grandtot = sum(grandtot,cost);
    datalines;
    squash 1.10
    apples 2.25
    juice 1.69
    ;
    run;

    data wrk;
    set groceries(rename=(cost=cost2 item=itm));
    run;

    its A

    ReplyDelete
  4. Anonymous6:26 AM

    The ans is B. Please refer this SAS link.
    http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131169.htm

    I request people who are not sure of the answer to refrain from posting here. It creates confusion.

    ReplyDelete
    Replies
    1. well said! I'm sick of idiots acting like 'know it alls' and confusing everyone wioth their wrong answers.

      Delete
    2. Anonymous5:11 AM

      Who the hell are you to brand anyone as an idiot. This is a forum to discuss and share knowledge. It is only natural to say what one think is correct.
      And anyone who knows the Actual "correct answer" would also give a valid logic to support the same. If you don't understand this basic premise, then just get lost and attend a SAS class somewhere.

      Delete
    3. Anonymous2:57 PM

      You are right! We are here to discuss things, we should allow different opinions cos nobody can be perfect.

      Delete
    4. Anonymous2:05 AM

      madarchodo padh lo chup chaap

      Delete
  5. midwesterner9:07 PM

    SASCERT,could you please intercede here?

    ReplyDelete
  6. The following code work and renames properly. This follows the syntax in Answer B.

    data rename;
    set groceries (rename = (grandtot = Grand_total Item = Fruit));
    run;

    When we use syntax in Answer A for the same code, you'll get an error similar to the following:

    15 data rename;
    16 set groceries (rename = (grandtot = Grand_total) (Item = Fruit));
    - -
    22 22
    200
    ERROR 22-7: Invalid option name (.

    ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, END,
    INDSNAME, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.

    ERROR 200-322: The symbol is not recognized and will be ignored.

    16 ! set groceries (rename = (grandtot = Grand_total) (Item = Fruit));
    ----
    22
    ERROR 22-7: Invalid option name ITEM.

    17 run;

    ReplyDelete
  7. Its got to be 'B' because after the first open brackets you place the rename keyword then open new brackets again to place all the renaming variables: ie

    (rename= (oldvar1=newvar1 oldvar2=newvar2));

    All the other answers have bad syntax.

    ReplyDelete
  8. Ans is B

    ReplyDelete
  9. yes, correct ans B as explained above by Eddy

    ReplyDelete
  10. Answer : B

    Reason: Default SAS syntax for Rename Option is to define it right beside the dataset in parenthesis.
    (Rename = (old1=new1 old2=new2 old3=new3....))

    ReplyDelete
  11. Anonymous9:18 PM

    B
    (rename= (oldvar1=newvar1 oldvar2=newvar2));

    ReplyDelete