BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
CathyVI
Pyrite | Level 9

Hi,

How do I find the word "elop' from the work Developmental. I want sas to output anywhere "elop" is within the variable. I thought about using the % in the data statement but got the wrong answer.

e.g

data check;

set test;

if %elop= 'developmental';

run; 

1 ACCEPTED SOLUTION

Accepted Solutions
jimbarbour
Meteorite | Level 14

Try

If INDEX(Variable_Name, 'elop');

 

The following code:

DATA	Have;
	LENGTH	Variable_Name		$32;
	INFILE	DATALINES	MISSOVER;
	INPUT	Variable_Name		$;
DATALINES;
Developmental
Experimental
Tempermental
Elope
Develop
Production
QualityControl
;
RUN;

DATA	Want;
	SET	Have;
	IF	INDEX(LOWCASE(Variable_Name), 'elop');
RUN;

Yields the following results:

jimbarbour_0-1627504258674.png

 

 

 

Jim

 

 

View solution in original post

3 REPLIES 3
jimbarbour
Meteorite | Level 14

Try

If INDEX(Variable_Name, 'elop');

 

The following code:

DATA	Have;
	LENGTH	Variable_Name		$32;
	INFILE	DATALINES	MISSOVER;
	INPUT	Variable_Name		$;
DATALINES;
Developmental
Experimental
Tempermental
Elope
Develop
Production
QualityControl
;
RUN;

DATA	Want;
	SET	Have;
	IF	INDEX(LOWCASE(Variable_Name), 'elop');
RUN;

Yields the following results:

jimbarbour_0-1627504258674.png

 

 

 

Jim

 

 

PaigeMiller
Diamond | Level 26

You can also use the FIND() function, which has an option that allows you to do the search independent of the case of the letters, if that's something you want to do.

--
Paige Miller
Reeza
Super User
FIND() function?

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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