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-6268%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ED%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6268%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%3EJ'ai%20un%20script%20JMP%20qui%20cr%C3%A9e%20une%20nouvelle%20colonne%20avec%20une%20formule.%20J'essaie%20de%20savoir%20comment%20d%C3%A9tecter%20si%20la%20colonne%20existe%20d%C3%A9j%C3%A0%20afin%20que%20je%20puisse%20ignorer%20sa%20cr%C3%A9ation%20et%20%C3%A9viter%20de%20g%C3%A9n%C3%A9rer%20des%20colonnes%20suppl%C3%A9mentaires.%20Je%20suis%20s%C3%BBr%20que%20c'est%20l%C3%A0%2C%20mais%20je%20ne%20le%20trouve%20pas%20dans%20la%20litt%C3%A9rature%20que%20j'ai.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMerci.%3C%2FP%3E%3CP%3EMike%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-55586%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-55586%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EVoici%20une%20version%20de%20ma%20logique%20qui%20est%20insensible%20%C3%A0%20la%20casse.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20open(%22%24sample_data%5CBig%20Class.jmp%22)%3B%0Acol_name_list%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(string)%3B%0A%2F%2F%20Convert%20all%20column%20names%20to%20uppercase%20for%20case-insensitive%20search%0Afor%20(i%20%3D%201%2C%20i%20%26lt%3B%3D%20nitems(col_name_list)%2C%20i%2B%2B%2C%0A%20col_name_list%5Bi%5D%20%3D%20uppercase(col_name_list%5Bi%5D)%3B%0A)%3B%0Anew_column%20%3D%20%22BMI%22%3B%0A%2F%2F%20English%20BMI%20Formula%20BMI%20%3D%20(%20Weight%20in%20Pounds%20%2F%20(%20Height%20in%20inches%5E2%20)%20)%20x%20703%0Aif%20(!contains(col_name_list%2C%20uppercase(new_column))%2C%0A%20%20%20%20dt%20%26lt%3B%3CNEW%20column%3D%22%22%3E%3C%2FNEW%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-55531%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-55531%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EMerci%20Mme%26nbsp%3B!%3CBR%20%2F%3E%20Seul%20votre%20exemple%20a%20fonctionn%C3%A9%20pour%20moi%2C%20car%20l'autre%20solution%20est%20sensible%20%C3%A0%20la%20casse.%20J'ai%20d%C3%BB%20utiliser%20le%20v%C3%B4tre%2C%20car%20je%20ne%20pouvais%20pas%20%C3%AAtre%20s%C3%BBr%20que%20la%20casse%20de%20mes%20caract%C3%A8res%20de%20cha%C3%AEne%20soit%20correcte.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6276%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6276%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPMroz%2C%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EPermettez-moi%20de%20commencer%20par%20confirmer%20que%20le%20code%20que%20vous%20avez%20%C3%A9crit%20a%20%C3%A9galement%20fonctionn%C3%A9%20pour%20moi%20et%20que%20l'explication%20que%20j'ai%20%C3%A9crite%20n'est%20pas%20coh%C3%A9rente%20avec%20le%20comportement%20de%20JMP%209%20ou%2010.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EApr%C3%A8s%20avoir%20lu%20votre%20r%C3%A9ponse%2C%20j'ai%20%C3%A9galement%20essay%C3%A9%20plusieurs%20combinaisons%20diff%C3%A9rentes%20d'instructions%20contains%20et%20if%20avec%20des%20listes%2C%20des%20cha%C3%AEnes%20et%20des%20nombres%20dans%20JMP%209%20et%2010.%20Bien%20que%20mes%20tentatives%20n'aient%20pas%20%C3%A9t%C3%A9%20exhaustives%2C%20tous%20mes%20r%C3%A9sultats%20sont%20coh%C3%A9rents%20avec%20les%20v%C3%B4tres.%20Au%20d%C3%A9part%2C%20lorsque%20j'ai%20lu%20votre%20premier%20message%2C%20je%20me%20suis%20souvenu%20d'un%20d%C3%A9pannage%20que%20j'avais%20effectu%C3%A9%20des%20ann%C3%A9es%20auparavant%2C%20o%C3%B9%20j'avais%20adopt%C3%A9%20l'utilisation%20de%20contains()%26gt%3B0.%20Je%20suis%20incapable%20de%20recr%C3%A9er%20le%20sc%C3%A9nario%26nbsp%3B%3B%20cependant%2C%20j'ai%20trouv%C3%A9%20les%20informations%20suivantes%20dans%20le%20guide%20de%20script%20JMP.%20Il%20d%C3%A9taille%20l'utilisation%20de%20contains%20avec%20%26gt%3B%200%2C%20ce%20qui%20peut%20%C3%AAtre%20appropri%C3%A9%20pour%20leur%20exemple%2C%20mais%20n'indique%20pas%20explicitement%20qu'il%20est%20ou%20n'est%20pas%20requis.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EPage%20136%20du%20guide%20de%20cr%C3%A9ation%20de%20scripts%20JMP%20version%2010%26nbsp%3B%3A%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%22Pour%20%C3%A9valuer%20si%20un%20%C3%A9l%C3%A9ment%20est%20dans%20une%20liste%2C%20utilisez%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3E%20Loc()%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%20et%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3E%20Contient()%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%20avec%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3E%20%26gt%3B0%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%20.%20Une%20valeur%20retourn%C3%A9e%20de%20z%C3%A9ro%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3Esignifie%20que%20l'%C3%A9l%C3%A9ment%20n'est%20pas%20dans%20la%20liste.%20Une%20valeur%20renvoy%C3%A9e%20de%201%20signifie%20que%20l'%C3%A9l%C3%A9ment%20est%20dans%20la%20liste%20au%20moins%20une%20fois.%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E...%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%22D%C3%A9couvrez%20si%20le%20nombre%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3E%205%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%20existe%20dans%20le%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3E%20numListe%26nbsp%3B%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3ENRow(Loc(numList%2C%205))%20%26gt%3B0%26nbsp%3B%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CEM%20style%3D%22font-size%3A%209pt%3B%20font-family%3A%20LucidaSansTypewriter%2CItalic%3B%22%3E0%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3EContient(numListe%2C%205)%20%26gt%3B0%26nbsp%3B%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CEM%20style%3D%22font-size%3A%209pt%3B%20font-family%3A%20LucidaSansTypewriter%2CItalic%3B%22%3E0%22%3C%2FEM%3E%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EJ'esp%C3%A8re%20que%20cela%20t'aides.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6275%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6275%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EBonjour%20wiebepo%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EJ'ai%20essay%C3%A9%20diff%C3%A9rentes%20combinaisons%20et%20la%20n%C3%A9gation%20d'un%20entier%20positif%2C%20quelle%20que%20soit%20sa%20taille%2C%20donne%20un%200.%20Mon%20code%20fonctionnera%20donc%20(dans%20JMP%209%20et%2010).Cela%20dit%2C%20j'appr%C3%A9cie%20les%20avertissements%26nbsp%3B%3A%20cette%20approche%20peut%20ne%20pas%20fonctionner%20dans%20toutes%20les%20langues.Cela%20m%C3%A9rite%20certainement%20d'autres%20tests.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eb%20%3D%202000000000000%3B%0A!b%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ELe%20journal%20affiche%26nbsp%3B%3A%3C%2FP%3E%0A%3CP%3E%3CSTRONG%20style%3D%22color%3A%20black%3B%20font-size%3A%2010.0pt%3B%20font-family%3A%20'Courier%20New'%3B%22%3E0%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESalutations%2C%3C%2FP%3E%0A%3CP%3EPMroz%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6274%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6274%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAussi%20pratique%20%C3%A0%20savoir.%20Je%20suis%20toujours%20heureux%20d'avoir%20un%20autre%20outil%20%C3%A0%20ajouter%20%C3%A0%20la%20bo%C3%AEte%20%C3%A0%20outils.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMerci.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6273%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6273%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EC'est%20tr%C3%A8s%20pratique%20%C3%A0%20savoir.%20Je%20vais%20devoir%20faire%20attention%20%C3%A0%20%C3%A7a.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EMerci%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6272%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6272%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EIl%20n'y%20a%20pas%20de%20fonction%20unique%20%C3%A0%20ma%20connaissance.%20Mais%3CEM%3E%20Est%20manquant()%3C%2FEM%3E%20en%20combinaison%20avec%3CEM%3E%20Est%20inscriptible()%3C%2FEM%3E%20peut%20faire%20l'affaire.%3C%2FP%3E%0A%3CP%3ELa%20colonne%20doit%20%C3%A9galement%20%C3%AAtre%20entour%C3%A9e%20d'une%20instruction%20Try()%20pour%20%C3%A9viter%20que%20le%20script%20ne%20s'arr%C3%AAte%20si%20la%20colonne%20n'existe%20pas.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24sample_data%5CBig%20Class.jmp%22%20)%3B%0A%20%0Anew_column%20%3D%20%22BMI%22%3B%0A%20%0AIf(%20Is%20Missing(%20Is%20Scriptable(%20Try(%20Column(%20new_column%20)%20)%20)%20)%2C%0A%20dt%20%26lt%3B%26lt%3B%20New%20Column(%20new_column%2C%20numeric%2C%20continuous%2C%20formula(%20703%20*%20%3Aweight%20%2F%20%3Aheight%20%2F%20%3Aheight%20)%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%20style%3D%22margin%3A%200.0px%200.0px%200.0px%200.0px%3B%20color%3A%20%23a70096%3B%22%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6271%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6271%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20background-color%3A%20%23ffffff%3B%22%3E%3CSPAN%20style%3D%22font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20black%3B%22%3EJe%20ne%20suis%20pas%20certain%20que%20cela%20soit%20vrai%20dans%20toutes%20les%20versions%20r%C3%A9centes%20de%20JMP.%20Je%20fais%20ce%20commentaire%20uniquement%20pour%20souligner%20une%20opportunit%C3%A9%20d'am%C3%A9liorer%20la%20robustesse%20du%20code.%20%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20background-color%3A%20%23ffffff%3B%22%3E%3CSPAN%20style%3D%22font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20black%3B%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20background-color%3A%20%23ffffff%3B%22%3E%3CSPAN%20style%3D%22font-style%3A%20inherit%3B%20font-size%3A%2010pt%3B%20font-family%3A%20'Courier%20New'%3B%20color%3A%20black%3B%22%3E'Contains'%20renvoie%20la%20position%20de%20l'%C3%A9l%C3%A9ment%2C%20ce%20qui%20est%20bien%20%C3%A0%20utiliser%20dans%20une%20instruction%20'if'%2C%20car%20z%C3%A9ro%20sera%20interpr%C3%A9t%C3%A9%20comme%20faux%20et%20une%20valeur%20positive%20sera%20interpr%C3%A9t%C3%A9e%20comme%20vraie.%20Lorsqu'il%20pr%C3%A9c%C3%A8de%20un%20contient%20avec%20un%20non%20'!'%2C%20la%20condition%20fonctionne%20lorsque%20l'%C3%A9l%C3%A9ment%20n'est%20pas%20pr%C3%A9sent%20ou%20lorsqu'il%20est%20pr%C3%A9sent%20en%20tant%20que%20premier%20%C3%A9l%C3%A9ment%26nbsp%3B%3B%20cependant%2C%20lorsque%20l'%C3%A9l%C3%A9ment%20n'est%20pas%20le%20premier%20(une%20valeur%20sup%C3%A9rieure%20%C3%A0%201)%2C%20le%20pas%20'!'%20peut%20%C3%A9chouer%20%C3%A0%20convertir%20la%20condition%20en%20fausse.%20Ceci%20peut%20%C3%AAtre%20%C3%A9vit%C3%A9%20en%20utilisant%20une%20comparaison%20'%26gt%3B0'%20avec%20le%20'contient'.%20Voir%20ci-dessous%20pour%20la%20syntaxe.%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24sample_data%5CBig%20Class.jmp%22%20)%3B%0A%20%0Acol_name_list%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(%20string%20)%3B%0A%20%0Anew_column%20%3D%20%22BMI%22%3B%0A%20%0A%2F%2F%20English%20BMI%20Formula%0A%2F%2F%20BMI%20%3D%20(%20Weight%20in%20Pounds%20%2F%20(%20Height%20in%20inches%20x%20Height%20in%20inches%20)%20)%20x%20703%0A%20%0AIf(%20!(Contains(%20col_name_list%2C%20new_column%20)%20%26gt%3B%200)%2C%0A%20dt%20%26lt%3B%26lt%3B%20New%20Column(%20%22BMI%22%2C%20numeric%2C%20continuous%2C%20formula(%20703%20*%20%3Aweight%20%2F%20%3Aheight%20%2F%20%3Aheight%20)%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%20style%3D%22font-family%3A%20'Helvetica%20Neue'%2C%20Helvetica%2C%20Arial%2C%20'Lucida%20Grande'%2C%20sans-serif%3B%20background-color%3A%20%23ffffff%3B%22%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6270%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6270%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMerci%2C%20%C3%A7a%20marche%20tr%C3%A8s%20bien%20pour%20moi.%20Je%20m'attendais%20%C3%A0%20trouver%20une%20fonction%20pour%20v%C3%A9rifier%20l'existence%2C%20mais%20cela%20fonctionne.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6269%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%26nbsp%3B%3A%20D%C3%A9terminer%20si%20une%20colonne%20existe%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6269%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%20style%3D%22margin-bottom%3A%200.0001pt%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20open(%22%24sample_data%5CBig%20Class.jmp%22)%3B%0A%20%0Acol_name_list%20%3D%20dt%20%26lt%3B%26lt%3B%20get%20column%20names(string)%3B%0A%20%0Anew_column%20%3D%20%22BMI%22%3B%0A%20%0A%2F%2F%20English%20BMI%20Formula%0A%2F%2F%20BMI%20%3D%20(%20Weight%20in%20Pounds%20%2F%20(%20Height%20in%20inches%20x%20Height%20in%20inches%20)%20)%20x%20703%0A%20%0Aif%20(!contains(col_name_list%2C%20new_column)%2C%0A%20%20%20%20%20%20dt%20%26lt%3B%3CNEW%20column%3D%22%22%3E%3C%2FNEW%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
mwechtal
Level III

Determining if a column exists

I have a JMP script that creates a new column with a formula in it. I'm trying to find out how to detect if the column already exists so that I can skip creating it, and avoid generating extra columns. I'm sure it's there, but I'm not finding it in the literature that I have.

Thanks.

Mike

10 REPLIES 10
wiebepo
Level III

Re: Determining if a column exists

PMroz,

Let me start by confirming that the code you wrote worked for me as well, and the explaination I wrote is not consistent with JMP 9 or 10 behavior.

After reading your reply, I also tried several different combinations of contains, and if statements with lists, string, and numbers in JMP 9 and 10. Although my attempts were not exhaustive, all of my results are consistent with yours. Initially, when I read your first post I recalled some troubleshooting that I had perform years prior where I had adopted the the use of contains()>0. I am unable to recreate the scenario; however, I did find the following information in the JMP scripting guide. It details using contains with >0, which may be appropriate for their example, but does not explicitly state that it is or is not required.

Page 136 of the JMP scripting guide version 10:

"To assess whether an item is in a list, use Loc() and Contains() with >0. A returned value of zero

means that the item is not in the list. A returned value of 1 means that the item is in the list at least once."

...

"Find out if the number 5 exists in the numList:

NRow(Loc(numList, 5)) >0;

0

Contains(numList, 5) >0;

0"

Hope this helps.