DATA Step, Macro, Functions and more

index function

Reply
Frequent Contributor
Posts: 82

index function

Hi,

Maybe someone of you knows - is there a function similar to index, only working from right side to left (not left to right as index does).

For example, in this case index is 3 and 4. But I would like to find which position counting from right side when first time appears '1' (that would be 2 and 5).

data b;
input a $8.;
index=index(a, '1');
datalines;
00101110
00010000
;
run;

Thanks for your ideas,
Ieva Message was edited by: ieva
Super Contributor
Super Contributor
Posts: 3,174

Re: index function

Explore the FIND function using a negative large-value (or a LENGTH() function) for the starting position.

Scott Barry
SBBWorks, Inc.
Frequent Contributor
Posts: 82

Re: index function

Thank you, this works as expected!
Ask a Question
Discussion stats
  • 2 replies
  • 126 views
  • 0 likes
  • 2 in conversation