BookmarkSubscribeRSS Feed
Bulleride
Obsidian | Level 7

Flat file structure is as below
1----5----10
dan 23 45
bob 44 50
sue 30 80
mam 40 50
The following code is submitted.

data temp;
infile ‘file specification’;
input x $ 1-3;
if x='sue' then input age 5-6;
else input height 8-9;
run;


what would be the value of variable AGE in the dataset TEMP when
variable X has the value ‘Sue’?
a) 30
b) 44
c) 40
d) 55
Ans: c

 

WHY c?

2 REPLIES 2
Astounding
PROC Star

A program is not obliged to read in all the data on every line.  You can pick and choose what you want to read and what you want to skip.  So when the INPUT statement ends, that's the signal to SAS that you're done with that line of data and don't want to read any more items from it.

 

In this program, then, the subsequent INPUT statement is reading from the next line of data.

Ksharp
Super User

input x $ 1-3;   will skip to next line .

input x $ 1-3 @;  will NOT skip to next line.

sas-innovate-2024.png

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.

 

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
  • 2 replies
  • 696 views
  • 1 like
  • 3 in conversation