SAS Studio

Write and run SAS programs in your web browser
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
AKHILA
Obsidian | Level 7

can anybody tell me the difference between find() and index() giving an example. 

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

find()

Syntax - 

FIND(string,substring<,modifiers><,startpos>)

"The FIND function searches string for the first occurrence of the specified substring, and returns the position of that substring. If the substring is not found in string, FIND returns a value of 0.

If startpos is not specified, FIND starts the search at the beginning of the string and searches the string from left to right.

    If startpos is specified, the absolute value of startpos determines the position at which to start the search.

    The sign of startpos determines the direction of the search."

 

index() -

Syntax

INDEX(source,excerpt)

"The INDEX function searches source, from left to right, for the first occurrence of the string specified in excerpt, and returns the position in source of the string's first character. If the string is not found in source, INDEX returns a value of 0.

If there are multiple occurrences of the string, INDEX returns only the position of the first occurrence."

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

find()

Syntax - 

FIND(string,substring<,modifiers><,startpos>)

"The FIND function searches string for the first occurrence of the specified substring, and returns the position of that substring. If the substring is not found in string, FIND returns a value of 0.

If startpos is not specified, FIND starts the search at the beginning of the string and searches the string from left to right.

    If startpos is specified, the absolute value of startpos determines the position at which to start the search.

    The sign of startpos determines the direction of the search."

 

index() -

Syntax

INDEX(source,excerpt)

"The INDEX function searches source, from left to right, for the first occurrence of the string specified in excerpt, and returns the position in source of the string's first character. If the string is not found in source, INDEX returns a value of 0.

If there are multiple occurrences of the string, INDEX returns only the position of the first occurrence."

AKHILA
Obsidian | Level 7

thank you sir

 

mkeintz
PROC Star

So don't leave this topic hanging.  Mark the solution response, however "trivial".

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
PeterClemmensen
Tourmaline | Level 20

The Find and Index function documentation sites explains the differences.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 4 replies
  • 28786 views
  • 2 likes
  • 4 in conversation