Hi,
My question is the code like,
data work.test;
title='A TALE OF TWO CITIES, CHARLES J. DICKENS'
WORD=SCAN(title,3,' ,');
run;
What is the value of word?
A. T
B. OF
C.DICKENS
D. ''MISSING CHARACTER VALUE
I have run this code in sas like,
data work1;
input title $ 1-39;
datalines;
A TALE OF TWO CITIES, CHARLES J. DICKENS
run;
data work1;
WORD=SCAN(title,3,' ,');
run;
And i got log message like,
So,
What will be the answer comes? As my logic answer sholde be missing character value!
You didn't include a set statement in your second datastep. e.g.
data work1; input title $ 1-39; datalines; A TALE OF TWO CITIES, CHARLES J. DICKENS run; data work1; set work1; WORD=SCAN(title,3,' ,'); run;
Art, CEO, AnalystFinder.com
You didn't include a set statement in your second datastep. e.g.
data work1; input title $ 1-39; datalines; A TALE OF TWO CITIES, CHARLES J. DICKENS run; data work1; set work1; WORD=SCAN(title,3,' ,'); run;
Art, CEO, AnalystFinder.com
If the "test" code doesn't include any external file references I would suggest that you start first by running the code as provided in the test.
For the question code as posted all of the answers are wrong unless you consider an empty dataset as "missing character value" as the code will not run at all. You are missng a ; at the end of line two.
data work1;
input title $ 1-55;
datalines;
A TALE OF TWO CITIES, CHARLES J. DICKENS
run;
data work1;
set work1;
WORD=SCAN(title,3,' ,');
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.