The following SAS program is submitted:
data work.products;
Product_Number = 5461;
Item = '1001';
Item_Reference = Item'/'Product_Number;
run;
Which one of the following is the value of the variable ITEM_REFERENCE in the output data set?
A. 1001/5461
B. 1001/ 5461
C. . (missing numeric value)
D. The value can not be determined as the program fails to execute due to errors.
Click Comment link to get answer
This comment has been removed by the author.
ReplyDeleteB is the right answer.
ReplyDeleteIf we use
=compress(item||'/'||product_number)
then the output will be A.
Sorry the ans is D. the program fails to execute due to errors. I just tried it.
DeleteD
ReplyDeleteD.
ReplyDeletesince there is no concatenate symbol between them.
actualy there is a concatenation symbol, this is not the proper question
DeleteD
ReplyDeleteD is righ
ReplyDelete133 Item_Reference = Item '/' Product_Number;
--- --------------
388 202
ERROR 388-185: Expecting an arithmetic operator.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
This comment has been removed by the author.
ReplyDeleteconcatenating operator is missing.
ReplyDeleteAnswer is D
Answer D
ReplyDeletedata work.products;
ReplyDeleteProduct_Number = 5461;
Item = '1001';
Item_Reference = Item||'/'||Product_Number;
run;
ans is B.
(A) Item_Reference = Item'/'Product_Number;
DeleteSAS tries to solve it as an arithmetic operation but quotation
puzzles SAS as it expects arithmetic operator here
Ans: D. The value can not be determined as the program fails to execute due to errors.
(B) Item_Reference = Item/Product_Number;
Just removing qoutation marks
Ans: Value of Item_Reference is 0.1832997619
(C) Item_Reference = Item||'/'||Product_Number;
Just adding concatenating operator
Ans : B. 1001/ 5461
(D) Item_Reference = compress(item||'/'||product_number);
Item_Reference = Item||'/'||put(Product_Number, 4.);
Item_Reference = CATX('/',Item,Product_Number);
Item_Reference = Item||'/'||strip(Product_Number);
To get the output as given in option A
Ans: A. 1001/5461
Correct answer is D.
ReplyDeleteconfusing !!!!!!!!!!!
ReplyDeletewats d right answer....
& why?
the right answer for the question as it is written above is "D" .. because of an error in the code.
DeleteSince this question has come up before (in other question sets) without code errors, readers are assuming a question typing fault .. if the variable are concatenated properly (not as shown above) then there will be some padding and therefore the answer would be "B" in such a case ..
this is just a very good reminder for all of us to scrutinize the question code very very carefully before committing to an answer (based on similar questions encountered) ... cheers !!
ans should be B.
ReplyDeletefor Product_Number Character expected but numerical got, so it automatically change it into Character by using best 12. begining from right.
So there are 12-4=8 spaces before 5461
if you put a number which has 12 bytes then there is no space before that number.
correct ans ist D. I tested it.
ReplyDeleteCopied : Ans is B and you are right.
ReplyDeletefor Product_Number Character expected but numerical got, so it automatically change it into Character by using best 12. beginning from right.
So there are 12-4=8 spaces before 5461
if you put a number which has 12 bytes then there is no space before that number.
How you come with best 12 spaces? Is that default???
Can you explain it.
Sakar Sham
SAS is automatically converting numeric to character and when it does that the format changes to best12. automatically and the value is right aligned. so there are leading spaces
DeleteMan I got sas 9.1 and before I had 9.2, little bit different.
ReplyDeleteIn this 3 different process I got 3 different answer. One time it gave me product of 0.183299
once it gave me 1001/ 5461
and now it is giving me none and answer should be D.
How to clear the log and out put and submit on 9.1 sas program?
ans is D.... read the question carefully before u ans... / symbol in the 4th line is quoted so the data fails to execute...incase if its not quoted charac variables are changed to numeric and the resulting observation will be 0.1832997619 for variable ITEM_REFERENCE
ReplyDeleteAnswer is D - The program fails to execute.
ReplyDelete-----------------------------------------------
Log shows:
430 Item_Reference = Item'/'Product_Number;
---
49
388
200
NOTE 49-169: The meaning of an identifier after a quoted string might change in a future SAS release.
Inserting white space between a quoted string and the succeeding identifier is
recommended.
ERROR 388-185: Expecting an arithmetic operator.
ERROR 200-322: The symbol is not recognized and will be ignored.
----------------------------------------------
Corrected codes to yield 1001/5461 as output are:
Code 1:
data work.products;
Product_Number = 5461;
Item = '1001';
Item_Reference = Item||'/'||put(Product_Number, 4.);
run;
Code 2:
data work.products;
Product_Number = 5461;
Item = '1001';
Item_Reference = CATX('/',Item,Product_Number);
run;
B.
ReplyDeleteHere you can use the put option to change the numeric to char, but in this example it is not necessary and sas will convert the numeric value to char by default. So we get the output as
1001/ 5461
Now, there is a gap after the slash symbol as sas right align numeric variable.
Sorry my explanation is supposed to be the other way round. In this example, sas will do automatic conversion of char variable to numeric. As in the statement
DeleteItem_Reference = input(Item,4.)||'/'||Product_Number
is done in sas by default.
So we get 1001/ 5461, with a gap after the slash symbol, as sas right align numeric values
good explanation - we get 1001/ 5461 if there is conctenation operator as 5461 i num value and so is right aligned. but with original question; ans is D - does not execute due to errors
DeleteAnswer is B
ReplyDeleteExplanation: Numeric formats right-align the result; character formats left-align the result. So 1001/ 5461- (In this case numeric value is falling towards right side) if eg: 26/DP (in this case character value is falling towards left side)
Answer is D.
ReplyDeleteI tested it using this program:
data ee;
product_number = 5461;
item = '1001';
item_reference = item'/'product_number;
run;
proc print data=ee;
run;
In the log, I got the error messages: "Expecting an arithmetic operator...The symbol is not recognized and will be ignored...The SAS System stopped processing this step because of errors."
There was no output from the proc print step. The log read: "No observations in data set WORK.EE."
but there are a pair of concatenation operators besides the delimiter
Deleteought to be
item_reference=item||'/'||product_number
B
ReplyDeleteD
ReplyDeleteThere is no such thing called automatic converter" So disappointing:D
Ok there is such converter if we try next question... But the converter does not work on this one. I tried and got an error. Answer is still D
DeleteGuys, actually the original question contain the concatenation operator
ReplyDeleteItem_Reference = Item||'/'||Product_Number
hello, a side question, the length of the item_reference, I get in sas as 17, could someone please explain the length. I dont know how its 17. please help. thank you in advance.
ReplyDeleteBBBBBBBBBBBBBBBBB
ReplyDeletetry the code below:
data test;
Product_Number = 5461;
Item= '1001';
Item_Reference = Item!!'/'!!Product_Number;
run;
proc print data=test; run;
still confused. item='1001' is a character variable. how can a character variable / a number variable?
ReplyDeleteThe original question is
ReplyDelete... Item_Reference=Item||'/'||Product_Number;
...
and the correct answer would be D.
I mean B.
Deleteif there are leading spaces then ans should be 1001/ 5461.
ReplyDeletethen why there is only one blank
D is right answer
ReplyDeleteIt's B. I tried it in SAS 9.4. I just copied the program without any change.
ReplyDeleteYour website is really nice and this is a great inspiring article.
ReplyDeleteGclub จีคลับ
gclub
goldenslot
the ans is B, checked it
ReplyDeletedata work.products;
Product_Number = 5461;
Item = '1001';
Item_Reference =Item||'/'||Product_Number;
run;
output : 1001/ 5461
data work.products_nospace;
Product_Number = 5461;
Item = '1001';
Item_Reference = compress(Item||'/'||Product_Number);
run;
ouput : 1001/5461
Quest Base SAS 41 is Wrong
ReplyDeleteCorrect is :
The following SAS program is submitted:
data work.products;
Product_Number = 5461;
Item = '1001';
Item_Reference = Item || '/' || Product_Number;
run;