BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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
2 REPLIES 2
LinusH
Tourmaline | Level 20
Just do a subsetting IF together with SUBSTR(). It could be convenient to use the _INFILE_= option ont INFILE statement.

/Linus
Data never sleeps
GertNissen
Barite | Level 11
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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 2 replies
  • 718 views
  • 0 likes
  • 3 in conversation