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;
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1069 views
  • 0 likes
  • 3 in conversation