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!
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
;
Yes, the line pointer is advanced with the next data step iteration, or an INPUT without a line hold.
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
;
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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.