Hi,
I want to take all records from the below file out where name variable as a certain phrase like "abc1".
In the file the new file will contain record 2 and 3 in the file below.
Thank you so much.
HHC
Data have;
input name $ 20.;
datalines;
cost_ab
value_abc1
textabc12_x
testabc
; run;
You can use 'contains' in a where statement:
data have2;
set have;
where name contains 'abc1';
run;
You can use 'contains' in a where statement:
data have2;
set have;
where name contains 'abc1';
run;
You can use either function contains, as proposed by @nehalsanghvi
or if index(name,'abc1') > 0
in case you are looking for digits in name you can use:
if indexc(name,'012345678') > 0
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.
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.