BookmarkSubscribeRSS Feed
sanyam13
Fluorite | Level 6

Ruth 39 11

jose  32 22

sue   30 33

john  40 44

 

data test;

infile 'employee';

input emp_name $1-4 ;

if emp_name = 'sue' then input age 7-8;

else input idnum 10-11;

run;

 

can you plz explain why i am getting 40 as value for age when name of the employee is 'sue' .

2 REPLIES 2
Tom
Super User Tom
Super User

The first INPUT statement reads one line. The second INPUT statement will read from the next line.

If you want to continue reading from the same line you need to add a trailing @ sign to the first INPUT statement so that SAS will stay on the current line.

 

Cynthia_sas
SAS Super FREQ

Hi:

  In addition to Tom's suggestion, if you took a slightly different approach, using simple list input (since the values are delimited by spaces) you don't need a conditional INPUT statement.

revise_datalines.png 

Just another possible approach.

 

Cynthia

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
  • 578 views
  • 0 likes
  • 3 in conversation