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
B
ReplyDeleteB
ReplyDeleteB
ReplyDeleteB
ReplyDeleteCould someone explain why is not A?
ReplyDeleteThese examples show the correct syntax for renaming variables using the RENAME statement:
Deleterename street=address;
rename time1=temp1 time2=temp2 time3=temp3;
rename name=Firstname
score1-score3=Newscore1-Newscore3;
b
ReplyDeletebecause A is wrong
ReplyDeleteright
Deletedata groceries;
ReplyDeleteinput 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
The ans is B. Please refer this SAS link.
ReplyDeletehttp://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.
well said! I'm sick of idiots acting like 'know it alls' and confusing everyone wioth their wrong answers.
DeleteWho 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.
DeleteAnd 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.
You are right! We are here to discuss things, we should allow different opinions cos nobody can be perfect.
Deletemadarchodo padh lo chup chaap
DeleteSASCERT,could you please intercede here?
ReplyDeleteThe following code work and renames properly. This follows the syntax in Answer B.
ReplyDeletedata 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;
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
ReplyDelete(rename= (oldvar1=newvar1 oldvar2=newvar2));
All the other answers have bad syntax.
Thanks so much.
DeleteB
ReplyDeleteAns is B
ReplyDeleteyes, correct ans B as explained above by Eddy
ReplyDeleteAnswer : B
ReplyDeleteReason: Default SAS syntax for Rename Option is to define it right beside the dataset in parenthesis.
(Rename = (old1=new1 old2=new2 old3=new3....))
B
ReplyDelete(rename= (oldvar1=newvar1 oldvar2=newvar2));
B
ReplyDeletehotmail sign up login
ReplyDelete