Page 1 of 1

Poschar for multiple variable

Posted: December 1st, 2012, 5:52 am
by Ronin
Hi all,

i have a multiple alpha variable with string "ABCDEFGHIJWZ". i need to convert them to numbers 1,2,3 .....
So A = 1, B = 2 etc.

I used poschar function. Its ok unltil a variable as two ore more characters ,

So if x = AB E then poschar returns me only the first, so 1 in clone field.

How can i set to returns me all , in this case 1 at clone 1, 2 at clone 2 etc ?????

Re: Poschar for multiple variable

Posted: March 6th, 2013, 8:43 pm
by Gregory Martin
See attached for a sample application that demonstrates how to do this. It's a little trickier than necessary because I made it a data entry application where you can see the results for yourself.

But the idea here is that you loop through each character of your alpha variable and then search for it in a string that includes all possibilities.
PROC GLOBAL

alpha (26) alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


PROC MULTPOS_FF

preproc

    
set behavior() canenter(notappl) on(noconfirm);


PROC NUMBERS

preproc

    
if curocc() <= length(strip(MULTALPH)) then
        NUMBERS =
poschar(MULTALPH[curocc():1],alphabet);

    
else
        NUMBERS =
notappl;

    
endif;

    
noinput;