BookmarkSubscribeRSS Feed
PoojaP1
Fluorite | Level 6

The contents of the raw data file TEAM are listed below:

--------10-------20-------30
Janice 10
Henri 11
Michael 11
Susan 12

The following SAS program is submitted:

data group;
infile 'team';
input name $15. age 2.;
file 'file-specification';
put name $15. +5 age 2.;
run;

Which one of the following describes the output created?

A. a raw data file only
B. a SAS data set named GROUP only
C. a SAS data set named GROUP and a raw data file
D. No output is generated as the program fails to execute due to errors.

 

I am not able to get a clear picture of how "+" pointer is working here. Could anyone please explain this ?

 

Thank you!

4 REPLIES 4
RahulG
Barite | Level 11

+5 would add 5 spaces after printing name variable. As name itself is 15 char long so age would be printed after 15 characters.

You can try giving +50 insted of+5 and see the log you would understand the usage. Try the below program.

data group;
/* infile 'team'; */
input name $15. age 2.;
/* file 'file-specification'; */
 put name $15.  +5 age 2.; 
datalines;
Janice         10
Henri          11
Michael        11
Susan          12
;
PoojaP1
Fluorite | Level 6

Thank you, I tried the below code. I have understood the use of "+" symbol here, but in the output I am only getting one record which is for Henri. Why is that so?

RahulG
Barite | Level 11

Above code is working fine. Try to see if you are missing something otherwise share your log.

ballardw
Super User

Look in your log. Do you see any messages about SAS went to the next line?

You may be requesting to read more data than exists on a single line.

 

Also when asking why something happened it often helps to post the code from the log along with any messages.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1493 views
  • 0 likes
  • 3 in conversation