BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cookiejar
Calcite | Level 5

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

2 REPLIES 2
HB
Barite | Level 11 HB
Barite | Level 11
Did you run it and see what it does?
Astounding
PROC Star

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.

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1118 views
  • 4 likes
  • 3 in conversation