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

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.

 

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