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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 598 views
  • 0 likes
  • 3 in conversation