1.

When Looking For Data Contained In A Character String Of 150 Bytes, Which Function Is The Best To Locate That Data: Scan, Index, Or Index C?

Answer»

INDEX: Searches a character expression for a string of CHARACTERS, and returns the position of the string's first character for the first OCCURRENCE of the string.

INDEX (source, excerpt)

it returns the position where the 2nd field is in the source

Eg:

str1 = 'Hi i am fine here. how are u there ? .....';

str2 = index(str1,'how'); --> str2 = 20

SCAN is to get a substring upto MENTIONED character. Scan function the best for locating the particular word specified in a ARGUMENT,scan function default length is 200bytes.

data k;

r='ganesh kumar';

u=scan(r,2);

proc print;

run;

result: kumar

INDEXC to locate only for mentioned one or more single character

INDEXC(character-value, 'char1','char2','char3', ..)

FIND: Searches for a specific substring of characters within a character string

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

it returns the position the substring is in

FINDC: To locate a character that appears or does not appear within a string. used to search for any one in a list of character values

INDEXW: Searches for the substring as a word that follows a space in the provided sentence

eg;string1= "there is a the here" ;

INDEXW(STRING1,"the")

result: 12 (the word "the")

INDEX: Searches a character expression for a string of characters, and returns the position of the string's first character for the first occurrence of the string.

INDEX (source, excerpt)

it returns the position where the 2nd field is in the source

Eg:

str1 = 'Hi i am fine here. how are u there ? .....';

str2 = index(str1,'how'); --> str2 = 20

SCAN is to get a substring upto mentioned character. Scan function the best for locating the particular word specified in a argument,scan function default length is 200bytes.

data k;

r='ganesh kumar';

u=scan(r,2);

proc print;

run;

result: kumar

INDEXC to locate only for mentioned one or more single character

INDEXC(character-value, 'char1','char2','char3', ..)

FIND: Searches for a specific substring of characters within a character string

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

it returns the position the substring is in

FINDC: To locate a character that appears or does not appear within a string. used to search for any one in a list of character values

INDEXW: Searches for the substring as a word that follows a space in the provided sentence

eg;string1= "there is a the here" ;

INDEXW(STRING1,"the")

result: 12 (the word "the")



Discussion

No Comment Found