BookmarkSubscribeRSS Feed
Calcite | Level 5

Given the raw data file EMPLOYEE:

----I----1 0---I----20---I----30

Ruth 39 11

Jose 32 22

Sue 30 33

John 40 44

The following SAS program is submitted:

data test;

infile `employee';

input employee_name $ 1-4;

if employee_name = `Ruth' then input idnum 10-11;

else input age 7-8;


What value does the variable IDNUM contain when the name of the employee is "Ruth"?

A. 11

B. 22

C. 33

D. (missing numeric value)

Thanks for answering in advance,

Smiley Happy



  There is a HUGE difference between showing the data in a "fixed pitch" font and showing the data in a proportional spaced font, especially when your INPUT statement uses column positions.

  Again, to find out the answer to this question, you would type the data into a file, save the file as EMPLOYEES on your hard drive. Then probably amend the INFILE statement to use a fully qualified path. So, for example, if you save EMPLOYEES into c:\temp, the only modification would be to alter the INFILE statement: INFILE 'C:\temp\employees';

  Instead of answering the question for you, I am curious what results you discovered when you ran the program.


Calcite | Level 5

I did run the program and it gave a data error. See log message below:

NOTE: Invalid data for idnum in line 3 1-2.

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9

3         Jose 32 22 10

employee_name=Ruth idnum=. age=. _ERROR_=1 _N_=1

NOTE: Invalid data for age in line 7 1-2.

7         John 40 44 10

employee_name=Sue idnum=. age=. _ERROR_=1 _N_=2

What is unconvincing is the IF-THEN logic being used, which obviously makes me question the authenticity of online sample papers available for Base SAS exam.

if employee_name = `Ruth' then input idnum 10-11;

else input age 7-8;

Thanks, anyways, Cynthia. Smiley Happy

Calcite | Level 5

Forgot to add that after running the program, the output window showed missing values for the variables IDNUM and AGE. NAMES did appear though.


Calcite | Level 5

Cynthia and everyone,

I am preparing for Base SAS certification exam and was looking for a few practice papers. Would you like to recommend any useful sites, links from where I could access sample questions either free of charge or maybe paid(but not too expensive!)? Smiley Happy

Much Appreciated!


Calcite | Level 5

hi cynthia,

please explain the how pointer is reading the data. i am unable to comprehend the outcome. please help.

Super User Tom
Super User

Unless the actual question has an indication that the lines are shorter than 11 characters then you cannot tell if the right answer is D or None of the above.

If we replace the spaces with periods the actual input line for "Ruth" could be either of the lines below. In the first the value will be missing as it will try to read from the next line when it runs out of characters.  In the second example the value will be 1 since it reads '1 ' from columns 10 and 11.






Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 4 in conversation