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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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