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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.