The following SAS program is submitted:
data work.test;
Title = 'A Tale of Two Cities, Charles J. Dickens';
Word = scan(title,3,' ,');
run;
Which one of the following is the value of the variable WORD in the output data set?
A. T
B. of
C. Dickens
D. ' ' (missing character value)
Click Comment link to get answer
Correct Answer is B
ReplyDeleteYa its B
ReplyDeleteD is the right answer
ReplyDeletewhy don't run the toy code on ur SAS?
ReplyDeleteit's B.
I tried it in SAS 9. The right answer is 'D.'
ReplyDeleteif the third parameter to the scan function is space and a comma (' ,') then answer is B, If third paramter is only a comma (',') then answer is D.
ReplyDeleteRight Explaination
Deleteu are smart
DeleteYou're dreamy!!! Let's go out!~~
Deletegenius
DeleteThe funny thing is, my SAS 9.0 result shows the result is D
ReplyDeleteThe answer is D since the delimiter here is specified as ','
ReplyDeleteIts specified as ' ,' with a space in it!
DeleteSorry I'm the one in the floor two place above. And I made the typo mistake the correct is B, the result with SAS 9.0 is "of", you can try it also by paste the code into the sas too.
ReplyDeleteSorry my bad. I did not see the space. The answer is B
ReplyDeleteB
ReplyDeleteB. Checked in SAS v.9.
ReplyDeletecorrect me if i am wrong... ash far ash i know, this is incorrect ashwell.
ReplyDeletecan some one please explain thanks
ReplyDeleteTo create the LastName variable to store the employee's last name, you write an assignment
ReplyDeletestatement that contains the following SCAN function:
LastName=scan(name,1,' ,');
Note that a blank and a comma are specified as delimiters. You can also write the function
without listing delimiters, because the blank and comma are default delimiters.
LastName=scan(name,1);
so answer is d
In this example, the placement of the quotations around the delimiter, the comma, is critical – if there were NO space (‘,’), the value returned would be ‘ ‘ (missing character value). However, having the space before the delimiter (' ,') returns the 'of', so it is 'B' instead of 'D'.
ReplyDeletePeople run the code and check ! answer is B
ReplyDeletewe can specify 2 delimiters in scan functions.so answer B.I executed it.
ReplyDeleteYou cannot specify a multi-character delimiter in scan, so ' ,' is actually specifying 2 delimiters, a comma and a space.
ReplyDeleteAdditionally, in this example the only comma is right next to a space. SAS treats consecutive delimiters as 1, so if the scan statement asked for word #7, the output would be 'J.'
Answer is B.
ReplyDeleteWanted to hear more logic.
Scan Variable Title 3rd word ( of ), is that space and ',' makes to take the whole word "of"?
A, C does not make any sense, D may be a wild guess. Close call and right answer is C.
Reason ? So we can answer correctly in exam.
I don't understand. Why does it take the whole word of "of"?
Deletethe freaking code has a space as a delimiter along with comma, thats why answer is B. I don't know how the hell they expect us to notice that without actually running the code during the exam!! if it was just a comma then it would be D. I tried both code in SAS.
ReplyDeleteWhat is the point of you guys pasting code in SAS to see the answer?
ReplyDeleteFunny how everyone wants to just get the answer right...guys you will not have SAS in the exam room!!
People should focus more on the logic why they think what the answer should be!! Come on people grow up!!
Here you guys think about these codes and what they will give you:
ReplyDeletedata work.test;
Title = 'A Tale of Two Cities, Charles $J. Di $ ckens';
Word = scan(title,7,' ');
run;
data work.test1;
Title = 'A Tale of Two Cities, Charles $J. Di $ ckens';
Word = scan(title,7,' $');
run;
data work.test2;
Title = 'A Tale of Two Cities, Charles $J. Di $ ckens';
Word = scan(title,7,'$');
run;
this prog is quite complicated .....
ReplyDeleteThis is a tricky question mostly because of the formatting in the blog. If the delimiter is ' ,' then the answer is B - (Of ).
ReplyDeleteHere both the delimiters are valid ' ' and ',' which can be combined and written as:
' ,' or ', '. So the third word that is separated by a space ' ' or a comma ',' is 'Of'.
This is what the question asks for.
However, the space is not very visible. So if there is no space in question, then the answer is missing. As there are no two commas to separate the strings into three 'words'. And the question asks for the third 'word' separated by the delimiter.
The answer is B
ReplyDeletebec space is default delimitre ans is b
ReplyDeleteB
ReplyDeleteanswer is D. reason is because in the code....Word = scan(title,3,' ,');... there is a comma in ','. if there wasnt any commas then it would be B because SAS is going by the spaces. in our case, it is going by comma and there is only one comma so it runs out and answer is missing.
ReplyDeleteCorrect answer is B, Here is the result from code:
ReplyDeletesubmitted code.
work.test;
Title = 'A Tale of Two Cities, Charles J. Dickens'; Word = scan(title,3,' ,');
run;
proc print data=retail;
run;
Result:
Obs: 1
Title: A Tale of Two Cities, Charles J. Dickens
Word: of
Correct answer is D.
ReplyDeleteB
ReplyDeleteGO TO tITLE THIRD WORD IS OF
ReplyDeleteB
Answer is B.
ReplyDeleteBecause SAS treats 2 delimiters as one.in this case we have space and comma ' ,'.Thus SAS will interpret only space and NOT comma and give us answer B.
IF only comma, then answer D
Hence for this question correct answer checked in SAS is B
From my experience, the logic behind this is not what you think. if you specify two delimiters, SAS will interpret either one as one delimiter, or both as one delimiter, not space only. To prove that, plz try to replace all space by comma. SAS will return 'of' as third word as well if you specify 'space + ,' as delimiter.
DeleteThx
I am not sure SAS has changed the logic in newer version
Forgot to mention, although the logical is subtle, but the answer is B anyway, if there is a space before ','
DeleteB
ReplyDeleteI have read your blog its very attractive and impressive
ReplyDeleteSAS Training in Bangalore