BookmarkSubscribeRSS Feed
GavyK
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;

run;

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

6 REPLIES 6
Cynthia_sas
SAS Super FREQ

Hi:

  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.

cynthia

GavyK
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

                                    
                             
GavyK
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.

Gavy

GavyK
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!

Gavy

Ashwani_singh
Calcite | Level 5

hi cynthia,

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

Tom
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.


----|----10---|----20---|----30

Ruth.39.11

Ruth.39.11....................

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!

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.

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
  • 6 replies
  • 2553 views
  • 0 likes
  • 4 in conversation