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

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?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 952 views
  • 0 likes
  • 4 in conversation