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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.