cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
New to using JMP? Hit the ground running with the Early User Edition of Discovery Summit. Register now, free of charge.
Register for our Discovery Summit 2024 conference, Oct. 21-24, where you’ll learn, connect, and be inspired.
%3CLINGO-SUB%20id%3D%22lingo-sub-5088%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EValider%20que%20le%20nom%20de%20la%20colonne%20existe%20avant%20de%20tracer%20le%20graphique%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-5088%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CP%3EBonjour%2C%20j'essaie%20de%20valider%20qu'une%20table%20de%20donn%C3%A9es%20contient%20un%20certain%20nom%20de%20colonne%20avant%20de%20cr%C3%A9er%20des%20graphiques%26nbsp%3B%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3Eanom1%20%3D%200%26nbsp%3B%3B%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20pour%20(colval%20%3D%3D%201%2C%20colval%20%26lt%3B%3D%20Ncols(dt)%2C%20colval%2B%2B%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20colName%20%3D%20Nom%20de%20la%20colonne%20(colval)%3B%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20si%20(colName%20%3D%3D%20%22nom1%22%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20anom1%20%3D%201%26nbsp%3B%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3CSTRONG%3E)%3B%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20si%20(anom1%20%3D%3D%201%2C%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20%2F%2F%20cr%C3%A9er%20un%20graphique%3C%2FSTRONG%3E%3CBR%20%2F%3E%3CSTRONG%3E%20)%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ECependant%2C%20la%20comparaison%20ne%20renvoie%20jamais%20true%20car%20%22name1%22%20est%20un%20type%20de%20donn%C3%A9es%20cha%C3%AEne%20et%20le%20nom%20de%20la%20colonne%20renvoy%C3%A9%20par%3CSTRONG%3E%20Nom%20de%20la%20colonne%20(colval)%3C%2FSTRONG%3E%20est%20un%20autre%20type%20de%20donn%C3%A9es.%3C%2FP%3E%3CP%3EComment%20puis-je%20obtenir%20une%20valeur%20de%20cha%C3%AEne%20%C3%A0%20partir%20d'un%20nom%20de%20colonne%20pour%20effectuer%20une%20comparaison%20de%20cha%C3%AEne%20valide%26nbsp%3B%3F%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMerci!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-5090%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20Valider%20que%20le%20nom%20de%20la%20colonne%20existe%20avant%20de%20repr%C3%A9senter%20graphiquement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-5090%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EFonctionne%2C%20super%20et%20beaucoup%20plus%20court%20que%20ce%20que%20je%20faisais.Merci.%3CSPAN%20__jive_emoticon_name%3D%22grin%22%20__jive_macro_name%3D%22emoticon%22%20class%3D%22jive_macro%20jive_macro_emoticon%20jive_emote%22%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2F5.0.2%2Fimages%2Femoticons%2Fgrin.gif%22%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-5089%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20Valider%20que%20le%20nom%20de%20la%20colonne%20existe%20avant%20de%20repr%C3%A9senter%20graphiquement%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-5089%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVous%20pouvez%20utiliser%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(string)%3B%20pour%20obtenir%20les%20noms%20de%20colonne%20sous%20forme%20de%20cha%C3%AEne%20au%20lieu%20d'un%20objet%20de%20colonne.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EEssayez%20cette%20seule%20ligne%20de%20code.%20Doit%20attribuer%201%20ou%200%20%C3%A0%20hasname1.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%20style%3D%22margin%3A%200.0px%200.0px%200.0px%200.0px%3B%22%3Eanom1%3CSPAN%20style%3D%22color%3A%20%23130098%3B%22%3E%20%3D%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%232400eb%3B%22%3E%20Contient%3C%2FSPAN%3E%3CSTRONG%3E%20(%3C%2FSTRONG%3E%20dt%3CSPAN%20style%3D%22color%3A%20%23130098%3B%22%3E%20%26lt%3B%26lt%3B%3C%2FSPAN%3E%20obtenir%20les%20noms%20de%20colonnes%3CSTRONG%3E%20(%3C%2FSTRONG%3E%20cha%C3%AEne%20de%20caract%C3%A8res%3CSTRONG%3E%20)%3C%2FSTRONG%3E%3CSPAN%20style%3D%22color%3A%20%23130098%3B%22%3E%20%2C%3C%2FSPAN%3E%3CSPAN%20style%3D%22color%3A%20%23a40095%3B%22%3E%20%22nom1%22%3C%2FSPAN%3E%3CSTRONG%3E%20)%3C%2FSTRONG%3E%3CSPAN%20style%3D%22color%3A%20%23130098%3B%22%3E%20%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22margin%3A%200.0px%200.0px%200.0px%200.0px%3B%22%3E%3CSPAN%20style%3D%22color%3A%20%23130098%3B%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%20style%3D%22margin%3A%200.0px%200.0px%200.0px%200.0px%3B%22%3E%3CSPAN%20style%3D%22color%3A%20%23130098%3B%22%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
senatorx
Level III

Validate column name exists before graphing

Hi,  I am trying to validate that a data table contains a certain column name prior to creating graphs:

hasname1 = 0;
     for (colval == 1, colval <= Ncols(dt), colval++,
           colName = Column Name(colval);
           if ( colName == "name1",
                 hasname1 = 1;

           );
if (hasname1 == 1,
      //create graph
);

However, the comparison never returns true because "name1" is a string data type, and the column name returned from Column Name(colval) is some other data type.

How can I get a string value from a Column Name to make a valid string comparison?

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Validate column name exists before graphing

You can use dt << get column names(string); to get column names as a string instead of a column object.

Try this single line of code. Should assign 1 or 0 to hasname1.

hasname1 = Contains( dt << get column names( string ), "name1" );



View solution in original post

2 REPLIES 2
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Validate column name exists before graphing

You can use dt << get column names(string); to get column names as a string instead of a column object.

Try this single line of code. Should assign 1 or 0 to hasname1.

hasname1 = Contains( dt << get column names( string ), "name1" );



senatorx
Level III

Re: Validate column name exists before graphing

Works, great, and much shorter than what I was doing.  Thank you.