cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-227514%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EConvertir%20alfabeto%20a%20d%C3%ADgitos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-227514%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ETengo%20una%20columna%20que%20contiene%20valores%20como%20MN%2C%20YZ%2C%20etc.%3C%2FP%3E%3CP%3ENecesito%20eliminar%20el%20espacio%20intermedio%2C%20intercambiar%20los%20caracteres%20y%20convertir%20el%20%C3%BAltimo%20alfabeto%20a%20d%C3%ADgito.%3C%2FP%3E%3CP%3EEso%20significa%20-%3C%2FP%3E%3CP%3Eentrada%3A%20MN%3C%2FP%3E%3CP%3Esalida%3A%20N13%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%C2%BFC%C3%B3mo%20puedo%20hacer%20esto%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-227527%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Convertir%20alfabeto%20a%20d%C3%ADgitos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-227527%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEsto%20funcionar%C3%A1%20para%20su%20caso%20visualizado%20...%20pero%20no%20s%C3%A9%20si%20est%C3%A1%20lo%20suficientemente%20completo.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ealphabet%3D%22ABCDEFGHIJKLMNOPQRSTUVWXYZ%22%3B%0Aword(2%2C%3Atargetvariable%2C%22%20%22)%20%7C%7C%20Char(%20contains(%20alphabet%2C%20word(1%2C%3Atargetvariable%2C%22%20%22)))%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%20Esta%20es%20una%20f%C3%B3rmula%20que%20se%20puede%20usar%20para%20una%20f%C3%B3rmula%20para%20una%20nueva%20columna.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-227547%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Convertir%20alfabeto%20a%20d%C3%ADgitos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-227547%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHola%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPruebe%20la%20siguiente%20f%C3%B3rmula%20(copiar%20-%20pegar%20en%20el%20Editor%20de%20f%C3%B3rmulas)%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EWord(%201%2C%20%3AColumn%201%2C%20%22%20%22%20)%20%7C%7C%20Char(%0A%20Hex%20To%20Number(%20Hex(%20Word(%202%2C%20%3AColumn%201%2C%20%22%20%22%20)%20)%20)%20-%2064%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EAqu%C3%AD%20hay%20una%20instant%C3%A1nea%20de%20c%C3%B3mo%20se%20ver%C3%A1%20la%20tabla%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20718px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22SIMPLE%20TABLE.PNG%22%20style%3D%22width%3A%20718px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F19498i366A8512D874001B%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22SIMPLE%20TABLE.PNG%22%20alt%3D%22SIMPLE%20TABLE.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-227550%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Convertir%20alfabeto%20a%20d%C3%ADgitos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-227550%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EGracias%20por%20la%20respuesta.%20Para%20MN%2C%20la%20salida%20esperada%20es%20N13.%20Pude%20cambiar%20la%20funci%C3%B3n%20de%20Word%20y%20hacer%20que%20esto%20funcione.%20Puede%20haber%20casos%20en%20los%20que%20la%20columna%201%20solo%20tiene%20un%20alfabeto%20como%20%22A%22.%20En%20este%20caso%2C%20necesito%20imprimir%20A0%20en%20la%20columna%202.%20%C2%BFC%C3%B3mo%20puedo%20extender%20el%20c%C3%B3digo%20para%20hacer%20esto%3F%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-227553%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Convertir%20alfabeto%20a%20d%C3%ADgitos%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-227553%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3Everifique%20si%20solo%20tiene%201%20palabra%20y%2C%20de%20ser%20as%C3%AD%2C%20cambie%20la%20respuesta%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eif(word(2%2C%20%3AColumn%201%2C%20%22%20%22)%20%3D%3D%20%22%22%2C%0A%20%20%20%20%20do%20what%20you%20want%20if%20only%20one%20letter%2C%0A%20%20%20%20Word(%201%2C%20%3AColumn%201%2C%20%22%20%22%20)%20%7C%7C%20Char(%0A%20Hex%20To%20Number(%20Hex(%20Word(%202%2C%20%3AColumn%201%2C%20%22%20%22%20)%20)%20)%20-%2064%0A%20%20%20%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
ENTHU
Level IV

Converting alphabet to digits

I have a column that contains vaalues like M N , Y Z etc.

I need to remove the space in between,swap the characters and convert last alphabet to digit.

That means -

input : M N

output : N13

 

How can I do this?

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Converting alphabet to digits

check to see if you only have 1 word and if so, then change the response

if(word(2, :Column 1, " ") == "",
     do what you want if only one letter,
    Word( 1, :Column 1, " " ) || Char(
	Hex To Number( Hex( Word( 2, :Column 1, " " ) ) ) - 64
    )
)
Jim

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Converting alphabet to digits

This will work for your displayed case....but I don't know if it is complete enough.

alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
word(2,:targetvariable," ") || Char( contains( alphabet, word(1,:targetvariable," ")))

  This is a formula that can be used for a formula for a new column. 

Jim
Thierry_S
Super User

Re: Converting alphabet to digits

Hi, 

 

Try the following Formula (copy - paste in the Formula Editor)

Word( 1, :Column 1, " " ) || Char(
	Hex To Number( Hex( Word( 2, :Column 1, " " ) ) ) - 64
)

Here is a snapshot of what the table will look like 

SIMPLE TABLE.PNG

Thierry R. Sornasse
ENTHU
Level IV

Re: Converting alphabet to digits

Thanks for the response.For M N , the expected output is N13. I was able to change the Word function and get this working. There can be cases when column 1 has only one alphabet like "A". In this case i need to print A0 in column 2. How can I extend the code to do this?
txnelson
Super User

Re: Converting alphabet to digits

check to see if you only have 1 word and if so, then change the response

if(word(2, :Column 1, " ") == "",
     do what you want if only one letter,
    Word( 1, :Column 1, " " ) || Char(
	Hex To Number( Hex( Word( 2, :Column 1, " " ) ) ) - 64
    )
)
Jim

Recommended Articles