Help using Base SAS procedures

Understanding the put function

Reply
Occasional Contributor
Posts: 5

Understanding the put function

I'm going through the results of a practice exam with the following question:

Given the SAS data set PERM.STUDENTS:

PERM.STUDENTS NAME AGE

--------- ------ Alfred 14

Alice13

Barbara13

Carol14

The following SAS program is submitted:

libname perm ‘SAS data library’;

data students;

set perm.students;

file ‘file specification’;

put name $15. @5 age 2.;

run;

What is written to the output raw data file?

The correct response is listed below:

Response:

----I----10---I----20---I----30

Alfr14

Alic13

Barb13a

Carol 4

I think I understand the first two (i.e. Alfr14 and Alic13), but I'm not sure why the second answer shouldn't be Barb1 or Barb14 and the third Caro14.

Would someone mind explaining the answer and possibly correcting it if it is incorrect?

Super User
Posts: 11,343

Re: Understanding the put function

Barb13a because put first puts the name: Barbara then goes to column 5 (the @5) and prints the age of 13.

I suspect there's something odd about the actual values of name and age for the Carol14 that we can't see as we don't have the data set.

Occasional Contributor
Posts: 5

Re: Understanding the put function

This is the exact question as it was asked. There was no additional information. I think there might have been a typographical error.

Super User
Posts: 11,343

Re: Understanding the put function

I did a web search and page SAS Base Certification: Base SAS 88 found this question but the response choice displayed was

Alfr14

Alic13

Barb13a

Caro14

note the difference from your post.

Occasional Contributor
Posts: 5

Re: Understanding the put function

Interesting. Most of them make sense to me except for the Barb13a. Why is there a trailing 'a' at the end?

Super User
Posts: 5,498

Re: Understanding the put function

The trailing "a" is the last character in "Barbara".  Writing AGE replaced columns 5 and 6, but didn't replace column 7.

Ask a Question
Discussion stats
  • 5 replies
  • 278 views
  • 0 likes
  • 3 in conversation