hi in my below file below is my file after trailer there is a (.)
So when i execute my data setep , it is telling 4 records have been read. the record after trilaer is being read. I do not want to read that . Any suggestion
data a;
input name $;
if trailer then delete;
datalines;
aa
bb
cc
Tailer
..
run;
Sorry, not really understanding you very well, you don't want any observations after/including the trailer one? Why not just remove them from the datalines step? You could add a retained flag:
data a;
input name $;
retain flag;
if _n_=1 then flag=0;
if trailer then flag=1;
if not flag then output;
datalines;
aa
bb
cc
Tailer
..
run;
The question is, why?
Hi dennis ,
I am sorry not getting your question according to my understanding if there are trailing blanks
remove it by it by input options.
If '..' is not an acceptable value in any of the previous observations you could.use the following:
DATA A;
INPUT NAME $ @;
IF NAME = '..' THEN STOP;
DATALINES;
AA
BB
CC
TRAILER
..
;
RUN;
The trailing @ holds the input record so that you can process the item conditionally. In this case we are telling SAS to stop processing once a '..' is read.
Alternately you could use:
DATA A;
INPUT NAME $ @;
IF NAME = '..' THEN DELETE;
DATALINES;
AA
BB
CC
TRAILER
..
RUN;
This will delete any occurrence of '..'.
I hope this helps.
Regards,
Scott
if name='Trailer' then stop;
Try this.
data have;
input name $10.;
output;
if name eq 'Tailer' then stop;
datalines;
aa
bb
cc
Tailer
..
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.