DATA Step, Macro, Functions and more

Informat code

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Informat code

The following SAS program is submitted using the raw data file as input:

  

data work.family; 

   infile 'file-specification'; 

   input @1 date_of_birth mmddyy10. 

         @15 first_name $5. 

         @25 age 3; 

run; 

 proc print data=work.family noobs; 

run; 

Which one of the following is the result?  

a.The program executes, but the age values are missing in the output. 

b.The program executes, but the date values are missing in the output.  

c.The program fails to execute because the age informat is coded incorrectly.  

d.The program fails to execute because the date informat is coded incorrectly.

 

This is one of SAS Practice Questions from SAS. The correct answer is A. I chose C. The informat for age is coded incorrectly. Since 

age is standard numeric input, it should use the w.d informat to specify a field width of 3 in the INPUT statement.

My understanding is that the period missed in the w.d informat is a syntax error. Then SAS fails to execute. Anyone please help?


Accepted Solutions
Solution
‎01-18-2017 05:47 PM
Super User
Posts: 5,082

Re: Informat code

Both of these would be the correct way to get the contents of column 3:

 

input @3 age 1.;

input age 3;

 

This also takes the contents of column 3:

 

input @25 age 3;

 

It essentially says, "Move to column 25.  Then get the contents of age from column 3."

 

Since column 3 contains a slash (part of the date), the AGE values are missing.

 

View solution in original post


All Replies
Frequent Contributor
Frequent Contributor
Posts: 89

Re: Informat code

Did you run it and see what it does?
Solution
‎01-18-2017 05:47 PM
Super User
Posts: 5,082

Re: Informat code

Both of these would be the correct way to get the contents of column 3:

 

input @3 age 1.;

input age 3;

 

This also takes the contents of column 3:

 

input @25 age 3;

 

It essentially says, "Move to column 25.  Then get the contents of age from column 3."

 

Since column 3 contains a slash (part of the date), the AGE values are missing.

 

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 206 views
  • 4 likes
  • 3 in conversation