DATA Step, Macro, Functions and more

reading only the obs from text file except the string

Reply
N/A
Posts: 0

reading only the obs from text file except the string

Hi,

The below is my text file and I would like to read all the observations except the string "NB: There are 5 observations inserted"

there could be any number of observations and any number of blanks between the last obs and the string

sample.txt

1 2 3 4
4 5 6 8
.
.
2 3 4 5
......
...

NB: There are 5 observations inserted

Revert me back if any doubts on question
Thanks and Regards
sam
Super User
Posts: 5,441

Re: reading only the obs from text file except the string

Posted in reply to deleted_user
Just do a subsetting IF together with SUBSTR(). It could be convenient to use the _INFILE_= option ont INFILE statement.

/Linus
Data never sleeps
SAS Employee
Posts: 174

Re: reading only the obs from text file except the string

Posted in reply to deleted_user
data test;
infile datalines;
input @;
if substr(_infile_,1,2) = 'NB' then delete;
input a b c e;
datalines;
1 2 3 4
4 5 6 8
2 3 4 5
NB: There are 5 observations inserted
;
run;
Ask a Question
Discussion stats
  • 2 replies
  • 129 views
  • 0 likes
  • 3 in conversation