BookmarkSubscribeRSS Feed
nirupama1
Fluorite | Level 6

data _null_;
xyz='She sells seashells? Yes, she does.';
startposexp=1-23;
whereisShe_ineg22=find(xyz,'She','i',startposexp);
put whereisShe_ineg22=;
run;

 

I should receive output whereisShe_ineg22=1 instead I am getting whereisShe_ineg22=14.
why?Let me  know.

 

Thanks,

Nirupama

2 REPLIES 2
Astounding
PROC Star

You should be using a value of 1 for STARTPOSEXP.  You are actually using a value of -22 (after performing math for 1 minus 23).  So the software computes the starting position by moving backwards from the right-hand side of the string.  Details are in the documentation for FIND.

ballardw
Super User
She sells seashells? Yes, she does.
                     ^
                     Position 22
             ^
             Postion 14

So you started searching backwards ad the Y.

 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 724 views
  • 0 likes
  • 3 in conversation