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;
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:
Jim
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:
Jim
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.
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!
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.