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?
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?
The SCAN function in SAS extracts words from a string based on specified delimiters. In this program, the delimiters specified are space and comma (' ,'). The program will tokenize the title 'A Tale of Two Cities, Charles J. Dickens' using these delimiters. The third word, considering spaces and commas as delimiters, is 'of'.
Answer should be B, delimiters mentioned are space and comma so the third word will be correct for this
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'.''' So Correct Answer is : B