BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
margi123
Fluorite | Level 6

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,

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 data work1;
63 input title $ 1-39;
64 datalines;
 
NOTE: The data set WORK.WORK1 has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
 
66 WORD=SCAN(title,3);
 
66 WORD=SCAN(title,3);
____
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
67 run;
68 data work1;
69 WORD=SCAN(title,3,' ,');
70 run;
 
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
69:11
NOTE: Variable title is uninitialized.
NOTE: The data set WORK.WORK1 has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
 
 
71
72 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
85

 

So,

What will be the answer comes? As my logic answer sholde be missing character value!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

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

Yavuz
Quartz | Level 8
You must put ";" after every program line. Please
Put ";" sign after line below and try again :

title='A TALE OF TWO CITIES, CHARLES J. DICKENS';


ballardw
Super User

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.

Saidurga1
Calcite | Level 5

 

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1973 views
  • 1 like
  • 5 in conversation