cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
%3CLINGO-SUB%20id%3D%22lingo-sub-6268%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBestimmen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%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%3EIch%20habe%20ein%20JMP-Skript%2C%20das%20eine%20neue%20Spalte%20mit%20einer%20Formel%20darin%20erstellt.%20Ich%20versuche%20herauszufinden%2C%20wie%20ich%20erkennen%20kann%2C%20ob%20die%20Spalte%20bereits%20vorhanden%20ist%2C%20sodass%20ich%20das%20Erstellen%20%C3%BCberspringen%20und%20das%20Generieren%20zus%C3%A4tzlicher%20Spalten%20vermeiden%20kann.%20Ich%20bin%20mir%20sicher%2C%20dass%20es%20da%20ist%2C%20aber%20ich%20finde%20es%20nicht%20in%20der%20Literatur%2C%20die%20ich%20habe.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EDanke.%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%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-55586%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHier%20ist%20eine%20Version%20meiner%20Logik%2C%20bei%20der%20die%20Gro%C3%9F-%2FKleinschreibung%20nicht%20ber%C3%BCcksichtigt%20wird.%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%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-55531%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EDanke%20Frau!%3CBR%20%2F%3E%20Bei%20mir%20hat%20nur%20Ihr%20Beispiel%20funktioniert%2C%20da%20bei%20der%20anderen%20L%C3%B6sung%20die%20Gro%C3%9F-%2FKleinschreibung%20beachtet%20wird.%20Ich%20musste%20Ihres%20verwenden%2C%20da%20ich%20nicht%20sicher%20sein%20konnte%2C%20ob%20die%20Gro%C3%9F-%2FKleinschreibung%20meiner%20Zeichenfolgenzeichen%20korrekt%20ist.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6276%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%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%3ELassen%20Sie%20mich%20zun%C3%A4chst%20best%C3%A4tigen%2C%20dass%20der%20von%20Ihnen%20geschriebene%20Code%20auch%20bei%20mir%20funktioniert%20hat%20und%20dass%20die%20von%20mir%20geschriebene%20Erkl%C3%A4rung%20nicht%20mit%20dem%20Verhalten%20von%20JMP%209%20oder%2010%20%C3%BCbereinstimmt.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ENachdem%20ich%20Ihre%20Antwort%20gelesen%20habe%2C%20habe%20ich%20in%20JMP%209%20und%2010%20auch%20mehrere%20verschiedene%20Kombinationen%20von%20%E2%80%9EContains%E2%80%9C-%20und%20%E2%80%9EIf%E2%80%9C-Anweisungen%20mit%20Listen%2C%20Zeichenfolgen%20und%20Zahlen%20ausprobiert.%20Obwohl%20meine%20Versuche%20nicht%20ersch%C3%B6pfend%20waren%2C%20stimmen%20alle%20meine%20Ergebnisse%20mit%20Ihren%20%C3%BCberein.%20Als%20ich%20Ihren%20ersten%20Beitrag%20las%2C%20erinnerte%20ich%20mich%20zun%C3%A4chst%20an%20einige%20Fehlerbehebungen%2C%20die%20ich%20Jahre%20zuvor%20durchgef%C3%BChrt%20hatte%20und%20bei%20denen%20ich%20die%20Verwendung%20von%20enth%C3%A4lt()%26gt%3B0%20%C3%BCbernommen%20hatte.%20Ich%20kann%20das%20Szenario%20nicht%20nachbilden%3B%20Ich%20habe%20jedoch%20die%20folgenden%20Informationen%20im%20JMP-Skripthandbuch%20gefunden.%20Es%20beschreibt%20die%20Verwendung%20von%20%E2%80%9EContains%E2%80%9C%20mit%20%26gt%3B0%2C%20was%20f%C3%BCr%20ihr%20Beispiel%20angemessen%20sein%20k%C3%B6nnte%2C%20gibt%20jedoch%20nicht%20explizit%20an%2C%20dass%20dies%20erforderlich%20ist%20oder%20nicht.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3ESeite%20136%20des%20JMP-Skripthandbuchs%20Version%2010%3A%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%E2%80%9EUm%20zu%20beurteilen%2C%20ob%20ein%20Element%20in%20einer%20Liste%20enthalten%20ist%2C%20verwenden%20Sie%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%20Und%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3E%20Enth%C3%A4lt()%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3E%20mit%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.%20Ein%20zur%C3%BCckgegebener%20Wert%20von%20Null%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20style%3D%22font-family%3A%20AGaramond-Regular%3B%20font-size%3A%2010pt%3B%22%3Ebedeutet%2C%20dass%20das%20Element%20nicht%20in%20der%20Liste%20enthalten%20ist.%20Ein%20zur%C3%BCckgegebener%20Wert%20von%201%20bedeutet%2C%20dass%20das%20Element%20mindestens%20einmal%20in%20der%20Liste%20vorhanden%20ist.%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%E2%80%9EFinden%20Sie%20heraus%2C%20ob%20die%20Nummer%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%20existiert%20in%20der%3C%2FSPAN%3E%3CSPAN%20style%3D%22font-family%3A%20LucidaSansTypewriter%3B%20font-size%3A%209pt%3B%22%3E%20AnzahlListe%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%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%3EEnth%C3%A4lt(numList%2C%205)%20%26gt%3B0%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%3EHoffe%20das%20hilft.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6275%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6275%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EHallo%20wiebepo%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIch%20habe%20verschiedene%20Kombinationen%20ausprobiert%20und%20das%20Negieren%20einer%20positiven%20Ganzzahl%2C%20egal%20wie%20gro%C3%9F%2C%20f%C3%BChrt%20zu%20einer%200.%20Mein%20Code%20funktioniert%20also%20(in%20JMP%209%20und%2010).Allerdings%20sch%C3%A4tze%20ich%20den%20Hinweis%20%E2%80%93%20dieser%20Ansatz%20funktioniert%20m%C3%B6glicherweise%20nicht%20in%20allen%20Sprachen.Es%20bedarf%20sicherlich%20weiterer%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%3EDas%20Protokoll%20zeigt%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%3EGr%C3%BC%C3%9Fe%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%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6274%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAuch%20praktisch%20zu%20wissen.%20Ich%20freue%20mich%20immer%2C%20ein%20weiteres%20Tool%20zur%20Toolbox%20hinzuf%C3%BCgen%20zu%20k%C3%B6nnen.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EDanke.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6273%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6273%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDas%20ist%20sehr%20praktisch%20zu%20wissen.%20Darauf%20muss%20ich%20achten.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EDanke%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6272%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6272%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEine%20einzelne%20Funktion%20ist%20mir%20nicht%20bekannt.%20Aber%3CEM%3E%20Wird%20vermisst()%3C%2FEM%3E%20in%20Kombination%20mit%3CEM%3E%20Ist%20skriptf%C3%A4hig()%3C%2FEM%3E%20kann%20den%20Trick%20machen.%3C%2FP%3E%0A%3CP%3EDie%20Spalte%20muss%20au%C3%9Ferdem%20von%20einer%20Try()-Anweisung%20eingeschlossen%20werden%2C%20um%20zu%20verhindern%2C%20dass%20das%20Skript%20stoppt%2C%20wenn%20die%20Spalte%20nicht%20vorhanden%20w%C3%A4re.%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%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%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%3EIch%20bin%20nicht%20sicher%2C%20ob%20dies%20in%20allen%20neueren%20Versionen%20von%20JMP%20zutrifft.%20Ich%20mache%20diesen%20Kommentar%20nur%2C%20um%20eine%20M%C3%B6glichkeit%20hervorzuheben%2C%20die%20Robustheit%20des%20Codes%20zu%20verbessern.%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%E2%80%9EContains%E2%80%9C%20gibt%20die%20Position%20des%20Elements%20zur%C3%BCck%2C%20was%20gut%20in%20einer%20%E2%80%9Eif%E2%80%9C-Anweisung%20verwendet%20werden%20kann%2C%20da%20Null%20als%20falsch%20und%20ein%20positiver%20Wert%20als%20wahr%20interpretiert%20wird.%20Wenn%20einem%20%E2%80%9EContains%E2%80%9C%20ein%20%E2%80%9Enicht!%E2%80%9C%20vorangestellt%20wird%2C%20funktioniert%20die%20Bedingung%2C%20wenn%20das%20Element%20nicht%20vorhanden%20ist%20oder%20wenn%20es%20als%20erstes%20Element%20vorhanden%20ist.%20Wenn%20das%20Element%20jedoch%20nicht%20das%20erste%20ist%20(ein%20Wert%20gr%C3%B6%C3%9Fer%20als%201)%2C%20wird%20das%20nicht%20%E2%80%9E!%E2%80%9C%20Die%20Konvertierung%20der%20Bedingung%20in%20%E2%80%9Efalsch%E2%80%9C%20kann%20fehlschlagen.%20Dies%20kann%20durch%20einen%20Vergleich%20%E2%80%9E%26gt%3B0%E2%80%9C%20mit%20%E2%80%9Eenth%C3%A4lt%E2%80%9C%20vermieden%20werden.%20Siehe%20unten%20f%C3%BCr%20die%20Syntax.%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%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-6270%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EDanke%2C%20das%20funktioniert%20bei%20mir%20ganz%20gut.%20Ich%20hatte%20erwartet%2C%20eine%20Funktion%20zum%20%C3%9Cberpr%C3%BCfen%20der%20Existenz%20zu%20finden%2C%20aber%20das%20funktioniert.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-6269%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EBetreff%3A%20Feststellen%2C%20ob%20eine%20Spalte%20vorhanden%20ist%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.