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

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