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

This might be a basic question, I know the definition is 

Single trailing is temporary, it is for the current iteration of the DATA step only.

But what exactly does it do? Does it mean to move to the next line at the end of the DATA step automatically or what else does it tell SAS to do?

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You didn't provide any context, so let's assume you are talking about the INPUT statement.

The trailing @ on an INPUT statement means to hold the input text line and the column pointer into that line of where the next INPUT will start reading.  You do this so you can read more values from the line.

For example you might want to first read the field that indicates the type of line and then depending on the type of line read different variables.

data want;
   infile 'mydata.txt' ;
   input type :$1. @ ;
   if type='A' then input id dob :date. ;
   else if type='B' then input age height weight ;
run;

Or you might have an unknown number of values on the line.

data want;
   infile 'myfile.txt' truncover ;
   length id col value 8 ;
   input id value @;
   do col=1 by 1 until(missing(value);
     output;
     input value @;
   end;
run;

The text you quoting is talking about the difference between using that and what happens when you have a double @ at the end of the INPUT statement.  When you use the double @ it means that the line/pointer does not move when you start the next iteration of the data step.  You would use the @@  when you want to read multiple observations from the same line.

data want;
   input id age @@;
cards;
1 10 2 20 3 14 4 15 
5 17 6 18
;

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

You didn't provide any context, so let's assume you are talking about the INPUT statement.

The trailing @ on an INPUT statement means to hold the input text line and the column pointer into that line of where the next INPUT will start reading.  You do this so you can read more values from the line.

For example you might want to first read the field that indicates the type of line and then depending on the type of line read different variables.

data want;
   infile 'mydata.txt' ;
   input type :$1. @ ;
   if type='A' then input id dob :date. ;
   else if type='B' then input age height weight ;
run;

Or you might have an unknown number of values on the line.

data want;
   infile 'myfile.txt' truncover ;
   length id col value 8 ;
   input id value @;
   do col=1 by 1 until(missing(value);
     output;
     input value @;
   end;
run;

The text you quoting is talking about the difference between using that and what happens when you have a double @ at the end of the INPUT statement.  When you use the double @ it means that the line/pointer does not move when you start the next iteration of the data step.  You would use the @@  when you want to read multiple observations from the same line.

data want;
   input id age @@;
cards;
1 10 2 20 3 14 4 15 
5 17 6 18
;
Amir
PROC Star

Hi,

 

According to the documentation:

 

The trailing @ prevents the next INPUT statement from automatically releasing the current input record and reading the next record into the input buffer. It is useful when you need to read from a record multiple times.

 

You can use the link to read more about Using Line-Hold Specifiers and Example 3: Holding a Record in the Input Buffer.

 

HTH.

 

 

Kind regards,

Amir.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 2160 views
  • 3 likes
  • 4 in conversation