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-415976%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EPregunta%20simple%3A%20c%C3%B3mo%20averiguar%20el%20n%C3%BAmero%20de%20una%20columna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-415976%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHola%20comunidad%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ES%C3%B3lo%20quiero%20aprender%20c%C3%B3mo%20encontrar%20un%20n%C3%BAmero%20de%20columna%20en%20JMP.%3C%2FP%3E%3CP%3EIntent%C3%A9%20usar%20Informaci%C3%B3n%20de%20columna%2C%20pero%20esta%20informaci%C3%B3n%20no%20aparece.%20Puedo%20escribir%20un%20n%C3%BAmero%20de%20columna%20en%20Cols%20%26gt%3B%20Selecci%C3%B3n%20de%20columnas%20%26gt%3B%20Ir%20a...%20%2C%20pero%20no%20quiero%20intentar%20adivinar.%3C%2FP%3E%3CP%3EPorque%20quiero%20usar%20el%20n%C3%BAmero%20de%20columna%20en%20mi%20secuencia%20de%20comandos%20para%20recorrerlo%20(por%20ejemplo%2C%20de%20la%20columna%20120%20a%20130).%20Pero%20para%20esto%20necesitaba%20descubrir%20que%20mi%20columna%20inicial%20(en%20mi%20caso%20%22I_nA_3_m30_NS%22)%20estaba%20ubicada%20en%20la%20columna%20120.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGracias%20por%20cualquier%20ayuda.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-415976%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EModelado%20estad%C3%ADstico%20avanzado%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAutomatizaci%C3%B3n%20y%20secuencias%20de%20comandos%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ECombinaci%C3%B3n%20y%20limpieza%20de%20datos%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ELa%20personalizaci%C3%B3n%20en%20masa%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-416292%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20simple%3A%20C%C3%B3mo%20saber%20el%20n%C3%BAmero%20de%20una%20columna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-416292%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESi%20desea%20permitir%20coincidencias%20parciales%20en%20varias%20columnas%2C%20puede%20dejar%20que%20'FilterColSelector()'%20haga%20parte%20del%20trabajo%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0A%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2Fbig%20class.jmp%22%20)%3B%0AallCols%20%3D%20dt%20%26lt%3B%26lt%3B%20getColumnNames(%22String%22)%3B%0A%0Afcs%20%3D%20Filter%20Col%20Selector(%20%26lt%3B%26lt%3B%20nameContains(%22eight%22))%3B%0AmatchingCols%20%3D%20fcs%20%26lt%3B%26lt%3B%20getItems%3B%0Afcs%20%26lt%3B%26lt%3B%20delete%3B%0A%0AmatchingColNumbers%20%3D%20%5B%5D%3B%0Afor(c%3D1%2C%20c%26lt%3B%3DNItems(matchingCols)%2C%20c%2B%2B%2C%20matchingColNumbers%20%3D%20matchingColNumbers%7C%7CLoc(allCols%2C%20matchingCols%5Bc%5D))%3B%0APrint(matchingColNumbers)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-416202%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20simple%3A%20C%C3%B3mo%20saber%20el%20n%C3%BAmero%20de%20una%20columna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-416202%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHola%2C%3C%2FP%3E%0A%3CP%3EBuen%20truco%3A%20el%20m%C3%A9todo%20que%20suger%C3%AD%20supone%20que%20busca%20el%20nombre%20completo%20de%20la%20columna%20de%20destino%2C%20lo%20cual%20no%20es%20v%C3%A1lido%20en%20su%20caso%20en%20el%20que%20busca%20una%20subcadena.%3C%2FP%3E%0A%3CP%3ED%C3%A9jame%20pensar%20en%20ello.%3C%2FP%3E%0A%3CP%3EMejor%2C%3C%2FP%3E%0A%3CP%3ETS%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-416038%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20simple%3A%20C%C3%B3mo%20saber%20el%20n%C3%BAmero%20de%20una%20columna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-416038%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELa%20funci%C3%B3n%20Contiene()%2C%20cuando%20se%20utiliza%20para%20comparar%20una%20lista%20JMP%2C%20devuelve%20solo%20coincidencias%20exactas.Si%20necesita%20buscar%20internamente%20cada%20elemento%20de%20la%20lista%2C%20deber%C3%A1%20hacer%20algo%20como%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2Fbig%20class.jmp%22%20)%3B%0A%0Acols%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(%20string%20)%3B%0A%0Atext%20%3D%20%22wei%22%3B%0A%0AFor(%20i%20%3D%201%2C%20i%20%26lt%3B%3D%20N%20Items(%20cols%20)%2C%20i%2B%2B%2C%20%0A%0A%20tcol%20%3D%20Contains(%20cols%5Bi%5D%2C%20text%20)%3B%0A%20If(%20tcol%20%26gt%3B%200%2C%0A%20%20tcol%20%3D%20i%3B%0A%20%20Break()%3B%0A%20)%3B%0A)%3B%0AShow(%20tcol%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-416017%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20simple%3A%20C%C3%B3mo%20saber%20el%20n%C3%BAmero%20de%20una%20columna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-416017%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EGracias%20por%20tu%20respuesta%2C%20es%20una%20buena%20idea%2C%20pero%20no%20me%20funcion%C3%B3%2C%20mi%20tcol%20era%200.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAqu%C3%AD%20est%C3%A1%20la%20variable%20cols%20(otra%20tabla%20adem%C3%A1s%20de%20la%20pregunta%20original)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%7B%22Etiqueta%22%2C%20%22FitA_%201%22%2C%20%22FitA_%202%22%2C%20%22FitA_%203%22%2C%20%22FitA_%204%22%2C%20%22FitA_%205%22%2C%20%22FitA_%206%22%2C%20%22FitA_%207%22%2C%20%22FitA_%208%22%2C%20%22FitA_%209%22%2C%20%22FitA_10%22%2C%20%22FitA_11%22%2C%20%22FitA_12%22%2C%20%22FitB_%201%22%2C%20%22FitB_%202%22%2C%20%22FitB_%203%22%2C%20%22FitB_%204%22%2C%20%22FitB_%205%22%2C%20%22FitB_%206%22%2C%20%22FitB_%207%22%2C%20%22FitB_%208%20%22%2C%20%22FitB_%209%22%2C%20%22FitB_10%22%2C%20%22FitB_11%22%2C%20%22FitB_12%22%2C%20%22F%22%2C%20%22H_%201%22%2C%20%22H_%202%22%2C%20%22H_%203%22%2C%20%22H_%204%22%2C%20%22H_%205%22%2C%20%22H_%206%22%2C%20%22H_%207%22%2C%20%22H_%208%22%2C%20%22H_%209%22%2C%20%22H_10%22%2C%20%22H_11%22%2C%20%22H_12%22%2C%20%22V2_%201%22%2C%20%22V2_%202%22%2C%20%22V2_%203%22%2C%20%22V2_%204%22%2C%20%22V2_%205%22%2C%20%22V2_%206%22%2C%20%22V2_%207%22%2C%20%22V2_%208%22%2C%20%22V2_%209%22%2C%20%22V2_10%22%2C%20%22V2_11%22%2C%20%22V2_12%22%2C%20%22V3_%201%22%2C%20%22V3_%202%22%2C%20%22V3_%203%20%22%2C%20%22V3_%204%22%2C%20%22V3_%205%22%2C%20%22V3_%206%22%2C%20%22V3_%207%22%2C%20%22V3_%208%22%2C%20%22V3_%209%22%2C%20%22V3_10%22%2C%20%22V3_11%22%2C%20%22V3_12%22%2C%20%22NAT%22%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ey%20lo%20intent%C3%A9%20con%20texto%20%3D%20%22FitB%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Epero%20tcol%20era%200%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-415986%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20simple%3A%20C%C3%B3mo%20saber%20el%20n%C3%BAmero%20de%20una%20columna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-415986%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EUna%20forma%20de%20abordar%20esto%20es%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2Fbig%20class.jmp%22%20)%3B%0A%0AcolNumber%20%3D%20Contains(%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(%20string%20)%2C%20%22height%22%20)%3B%0AShow(%20colNumber%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-415982%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Pregunta%20simple%3A%20C%C3%B3mo%20saber%20el%20n%C3%BAmero%20de%20una%20columna%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-415982%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHola%2C%3C%2FP%3E%0A%3CP%3EAqu%C3%AD%20hay%20un%20m%C3%A9todo%20para%20devolver%20la%20posici%C3%B3n%20relativa%20de%20la%20primera%20columna%20que%20coincide%20con%20un%20patr%C3%B3n%20de%20texto%20(a%20mi%20cuidado%20%22VISITA%22)%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20default%20to%20here%20(1)%3B%0A%0Adt%20%3D%20current%20data%20table%20()%3B%0A%0Acols%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names%20(string)%3B%0A%0Atext%20%3D%20%22VISIT%22%3B%0A%0Atcol%20%3D%20contains%20(cols%2C%20text)%3B%0A%0Ashow%20(tcol)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ED%C3%A9janos%20saber%20si%20eso%20funciona%20para%20ti.%3C%2FP%3E%0A%3CP%3EMejor%2C%3C%2FP%3E%0A%3CP%3ETS%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
maswan
Level I

Simple Question: How to find out a column number

Hello Community,

 

i just want to learn how to find out a column number in JMP. 

I tried using Column Info, but this information is not there. I can type a column number in Cols > Column Selection > Go to.. , but I don't want to try to guess.

Because I want to use the Column Number in my Script to loop over it (for example from column 120 to 130). But for this I needed to find out, that my starter Column (in my case "I_nA_3_m30_NS")  was located on the column 120..

 

Thanks for any help.

 

1 ACCEPTED SOLUTION

Accepted Solutions
ian_jmp
Level X

Re: Simple Question: How to find out a column number

If you want to allow for partial matches across multiple columns, you could let 'FilterColSelector()' do some of the work:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );
allCols = dt << getColumnNames("String");

fcs = Filter Col Selector( << nameContains("eight"));
matchingCols = fcs << getItems;
fcs << delete;

matchingColNumbers = [];
for(c=1, c<=NItems(matchingCols), c++, matchingColNumbers = matchingColNumbers||Loc(allCols, matchingCols[c]));
Print(matchingColNumbers);

View solution in original post

6 REPLIES 6
Thierry_S
Super User

Re: Simple Question: How to find out a column number

Hi,

Here is one method to return the relative position of the first column matching a text pattern (in my care "VISIT"):

Names default to here (1);

dt = current data table ();

cols = dt << get column names (string);

text = "VISIT";

tcol = contains (cols, text);

show (tcol);

Let us know if that works for you.

Best,

TS

Thierry R. Sornasse
maswan
Level I

Re: Simple Question: How to find out a column number

Thank you for your reply, is a good idea, but it didn't work for me, my tcol was 0.

 

Here is the cols variable (another table than the original question):

 

{"Tag", "FitA_ 1", "FitA_ 2", "FitA_ 3", "FitA_ 4", "FitA_ 5", "FitA_ 6", "FitA_ 7", "FitA_ 8", "FitA_ 9", "FitA_10", "FitA_11", "FitA_12", "FitB_ 1", "FitB_ 2", "FitB_ 3", "FitB_ 4", "FitB_ 5", "FitB_ 6", "FitB_ 7", "FitB_ 8", "FitB_ 9", "FitB_10", "FitB_11", "FitB_12", "F", "H_ 1", "H_ 2", "H_ 3", "H_ 4", "H_ 5", "H_ 6", "H_ 7", "H_ 8", "H_ 9", "H_10", "H_11", "H_12", "V2_ 1", "V2_ 2", "V2_ 3", "V2_ 4", "V2_ 5", "V2_ 6", "V2_ 7", "V2_ 8", "V2_ 9", "V2_10", "V2_11", "V2_12", "V3_ 1", "V3_ 2", "V3_ 3", "V3_ 4", "V3_ 5", "V3_ 6", "V3_ 7", "V3_ 8", "V3_ 9", "V3_10", "V3_11", "V3_12", "NAT"}

 

and I tried with text = "FitB"

 

but tcol was 0

txnelson
Super User

Re: Simple Question: How to find out a column number

The Contains() function when used to compare across a JMP List, returns only exact matches.  If you need to look internally for each element in the list, you will need to do something like:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

cols = dt << get column names( string );

text = "wei";

For( i = 1, i <= N Items( cols ), i++, 

	tcol = Contains( cols[i], text );
	If( tcol > 0,
		tcol = i;
		Break();
	);
);
Show( tcol );

 

Jim
Thierry_S
Super User

Re: Simple Question: How to find out a column number

Hi,

Good catch: the method I suggested assumes that you look for the entire name of the target column which is not valid in your case where you look for a substring.

Let me think about it.

Best,

TS

Thierry R. Sornasse
ian_jmp
Level X

Re: Simple Question: How to find out a column number

If you want to allow for partial matches across multiple columns, you could let 'FilterColSelector()' do some of the work:

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/big class.jmp" );
allCols = dt << getColumnNames("String");

fcs = Filter Col Selector( << nameContains("eight"));
matchingCols = fcs << getItems;
fcs << delete;

matchingColNumbers = [];
for(c=1, c<=NItems(matchingCols), c++, matchingColNumbers = matchingColNumbers||Loc(allCols, matchingCols[c]));
Print(matchingColNumbers);
txnelson
Super User

Re: Simple Question: How to find out a column number

One way to approach this is:

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );

colNumber = Contains( dt << get column names( string ), "height" );
Show( colNumber );
Jim

Recommended Articles