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-47053%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EContare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47053%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECiao%2C%20sto%20cercando%20di%20creare%20una%20nuova%20colonna%20nel%20mio%20set%20di%20dati%20che%20conta%20il%20numero%20di%20volte%20in%20cui%20una%20parola%20specifica%20appare%20in%20una%20stringa.%20Le%20parole%20sono%20separate%20da%20%22*%22%20in%20ogni%20riga.%3C%2FP%3E%3CP%3ETabella%20di%20esempio%3A%3C%2FP%3E%3CP%3EElenco%20degli%20animali%3C%2FP%3E%3CP%3E1%20cane*cane*gatto*uccello*cane%3C%2FP%3E%3CP%3E2%3CSPAN%3E%20cane*cane*gatto*uccello*cane*cane%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EL'uscita%20dovrebbe%20essere%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EConteggio%20dei%20cani%20della%20lista%20degli%20animali%3C%2FP%3E%3CP%3E1%20cane*cane*gatto*uccello*cane%203%3C%2FP%3E%3CP%3E2%3CSPAN%3E%20cane*cane*gatto*uccello*cane*cane%204%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EPu%C3%B2%20fornire%20ulteriori%20informazioni%20se%20necessario.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-390114%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-390114%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EN%20Rows(%20Loc(%20Words(%20%3AColumn%201%2C%20%22*%22%20)%2C%20%22dog%22%20)%20)%20%2B%0AN%20Rows(%20Loc(%20Words(%20%3AColumn%201%2C%20%22*%22%20)%2C%20%22cat%22%20)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-390113%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-390113%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECIAO%2C%3C%2FP%3E%3CP%3ECome%20cambierei%20la%20funzione%20per%20contare%20il%20numero%20di%20occorrenze%20sia%20di%20cane%20che%20di%20gatto%3F%3C%2FP%3E%3CP%3EHo%20provato%20l'O%2C%20ma%20questo%20non%20funziona%20correttamente.%3C%2FP%3E%3CP%3EGrazie%3C%2FP%3E%3CP%3EOnjai%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-184860%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184860%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMi%20piace%20quest'ultimo!%20Sembra%20che%20funzioner%C3%A0%20effettivamente%20fino%20a%2016%20bit%3B%2017%20numeri%20consecutivi%20non%20possono%20essere%20memorizzati%20in%20un%20numero%20a%20doppia%20precisione.%20L'operatore%20%3A%3A%20crea%20una%20matrice%2C%20e%20dopo%20c'%C3%A8%20molta%20matematica%20matriciale.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELe%20parole%20funzione%20potrebbero%20essere%20le%20migliori%20per%20un%20uso%20generale...essendo%20facili%20da%20spiegare...%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-184498%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-184498%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EAltre%20due%20alternative.%3C%2FP%3E%0A%3CP%3EUsa%20il%3CEM%3E%20Parole()%3C%2FEM%3E%20funzione%20con%20una%20stringa%20vuota%20come%20delimitatore%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eb%20%3D%20111001010%3B%0AN%20Row(Loc(Words(Char(b)%2C%20%22%22)%2C%20%221%22))%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EO%20semplicemente%20con%20la%20matematica%20(cio%C3%A8%20senza%20convertire%20il%20numero%20in%20stringa).%20Per%20esempio%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eb%20%3D%20111001010%3B%0ASum(Mod(Round(b%20%2F%2010%20%5E%20(Floor(Log10(b%20%2B%201))%20%3A%3A%200))%2C%2010))%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-183926%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-183926%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESi%20prega%20di%20trovare%20una%20delle%20alternative.%20Esegui%20lo%20script%20per%20creare%20una%20tabella.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENew%20Table(%20%22Counting%20Ones%22%2C%0A%20Add%20Rows(%205%20)%2C%0A%20New%20Column(%20%22Number%22%2C%0A%20%20Numeric%2C%0A%20%20%22Continuous%22%2C%0A%20%20Format(%20%22Best%22%2C%2017%20)%2C%0A%20%20Set%20Values(%20%5B111000010100001%2C%2010101%2C%2011111%2C%200%2C%20101010101%5D%20)%2C%0A%20%20Set%20Display%20Width(%20132%20)%0A%20)%2C%0A%20New%20Column(%20%22Count%20of%20One%22%2C%0A%20%20Numeric%2C%0A%20%20%22Ordinal%22%2C%0A%20%20Format(%20%22Best%22%2C%2012%20)%2C%0A%20%20Formula(%0A%20%20%20Length(%20Char(%20%3ANumber%20)%20)%20-%20Length(%0A%20%20%20%20Substitute(%20Char(%20%3ANumber%20)%2C%20%221%22%2C%20%22%22%20)%0A%20%20%20)%0A%20%20)%2C%0A%20%20Set%20Display%20Width(%20102%20)%0A%20)%0A)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-183551%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-183551%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESembra%20che%20i%20tuoi%20dati%20siano%20numerici%20(gi%C3%A0%20base%2010!)%20Quindi%20potresti%20dover%20usare%20char(value)%20per%20riportarli%20a%20una%20rappresentazione%20di%20stringa.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-183550%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-183550%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EMolti%20modi%20per%20farlo.%20Eccone%20uno.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EASCIIcode%20%3D%20blobtomatrix(chartoblob(%221%22)%2C%22int%22%2C1%2C%22big%22)%5B1%5D%3B%20%20%2F%2F%2049%0Aintermediate%3Dblobtomatrix(chartoblob(%220101111001010%22)%2C%22int%22%2C1%2C%22big%22)%3D%3DASCIIcode%3B%0A%2F%2F%20intermediate%3D%5B0%2C%201%2C%200%2C%201%2C%201%2C%201%2C%201%2C%200%2C%200%2C%201%2C%200%2C%201%2C%200%5D%0Asum(intermediate)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ELa%20riga%201%20%C3%A8%20solo%20un%20modo%20per%20ottenere%20il%20codice%20ASCII%20per%20il%20carattere%20ASCII%20%221%22%2C%20restituito%20in%20una%20matrice%20di%201%20elemento.%3C%2FP%3E%0A%3CP%3ELa%20riga%202%20%C3%A8%20simile%2C%20ma%20ottiene%20un%20array%20pi%C3%B9%20grande%20e%20lo%20confronta%20con%20il%20codice%20desiderato%2C%20ottenendo%20il%20valore%20nel%20commento%20della%20riga%203.%3C%2FP%3E%0A%3CP%3ELa%20riga%204%20somma%20solo%20gli%20elementi.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-183547%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-183547%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECIAO%3C%2FP%3E%3CP%3ECosa%20succede%20se%20non%20c'%C3%A8%20un%20delimitatore%2C%20ad%20esempio%20vorrei%20contare%20quanti%20%221%22%20in%20una%20stringa%20binaria%20111001010%3F%3C%2FP%3E%3CP%3ECome%20posso%20ottenere%20risultati%20di%20questo%20tipo%3F%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20146px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20146px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20146px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20146px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20146px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20146px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Capture.JPG%22%20style%3D%22width%3A%20146px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F15927i9874A1985ADE52A7%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Capture.JPG%22%20alt%3D%22Capture.JPG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGrazie%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-49192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-49192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EPosso%20confermare%20che%20la%20funzione%20Loc()%20non%20%C3%A8%20specifica%20di%20JMP%20Pro.%20%C3%88%20disponibile%20in%20JMP.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-49189%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-49189%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELa%20documentazione%20per%20JMP%2013%20non%20indica%20che%20la%20funzione%20LOC()%20%C3%A8%20solo%20una%20funzione%20di%20JMP%20Pro.Lo%20convaliderei%20eseguendo%20l'esempio%20di%20funzione%20LOC()%20nell'indice%20di%20scripting%3C%2FP%3E%0A%3CP%3EAiuto%3D%3D%26gt%3BIndice%20degli%20script%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0AShow(%20Loc(%20%5B1%200%201%200%201%200%5D%20)%20)%3B%0AShow(%20Loc(%20%7B%22A%22%2C%202%2C%203%2C%202%2C%205%2C%202%2C%204%2C%20%5B1%205%5D%7D%2C%202%20)%20)%3B%0AShow(%0A%20Loc(%20%7B%22A%22%2C%202%2C%203%2C%202%2C%205%2C%202%2C%204%2C%20%5B1%205%5D%7D%2C%20%5B1%205%5D%20)%0A)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-49186%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-49186%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELa%20funzione%20Loc()%20esiste%20solo%20in%20JMP%20Pro%3F%3C%2FP%3E%3CP%3EC'%C3%A8%20un%20modo%20per%20contare%20parole%20o%20simboli%20specifici%20in%20una%20stringa%20in%20JMP%20normale%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2687%22%20target%3D%22_blank%22%3E%40txnelson%3C%2FA%3E%20ha%20scritto%3A%3CBR%20%2F%3E%3CP%3EEcco%20la%20formula%20per%20contare%20il%20numero%20di%20volte%20che%20%22cane%22%20appare%20in%20una%20data%20colonna%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EN%20Rows(%20Loc(%20Words(%20%3AColumn%201%2C%20%22*%22%20)%2C%20%22dog%22%20)%20)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F8291i92EADDB618C58704%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22agaddis.GIF%22%20alt%3D%22agaddis.GIF%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47077%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47077%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ELa%20seguente%20formula%20trover%C3%A0%20tutti%20gli%20elementi%20con%20la%20stringa%20%22dog%22%20trovata%20al%20suo%20interno%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EwordList%3Dwords(st%2C%22*%22)%3B%0Acount%3D0%3Bfor(i%3D1%2Ci%26lt%3B%3Dn%20items(wordList)%2Ci%2B%2B%2Ccount%3Dsum(count%2Ccontains(wordList%5Bi%5D%2C%22dog%22)))%3B%0Acount%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47075%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47075%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ECome%20funzionerebbe%20per%20le%20parole%20jolly%3F%20Ad%20esempio%2C%20se%20cane%20avesse%20cane1%20e%20un%20altro%20dicesse%20cane2%3F%20Vorrei%20ancora%20che%20contasse%20tutte%20le%20parole%20del%20cane.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47070%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47070%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EGrazie!!%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-47062%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-47062%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EEcco%20la%20formula%20per%20contare%20il%20numero%20di%20volte%20che%20%22cane%22%20appare%20in%20una%20data%20colonna%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EN%20Rows(%20Loc(%20Words(%20%3AColumn%201%2C%20%22*%22%20)%2C%20%22dog%22%20)%20)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22agaddis.GIF%22%20style%3D%22width%3A%20459px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F8291i92EADDB618C58704%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22agaddis.GIF%22%20alt%3D%22agaddis.GIF%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-724585%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-724585%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Emolte%20grazie%2C%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F3605%22%20target%3D%22_blank%22%3E%40ian_jmp%3C%2FA%3E%20.%3C%2FP%3E%3CP%3EIn%20realt%C3%A0%2C%20non%20mi%20aspettavo%20che%20%3CFONT%20face%3D%22courier%20new%2Ccourier%22%3ELength%20-%20Length%3C%2FFONT%3E%20fosse%204%20volte%20pi%C3%B9%20veloce%20di%20%3CFONT%20face%3D%22courier%20new%2Ccourier%22%3EN%20righe(Loc%20())...%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FWafer%20Stacked.jmp%22%20)%3B%0A%0A%0A%2F%2F%20Recode%20column%3A%20Lot_Wafer%20Label%0ALocal(%20%7Bdt%7D%2C%0A%09dt%20%3D%20Data%20Table(%20%22Wafer%20Stacked%22%20)%3B%0A%09dt%20%26lt%3B%26lt%3B%20Begin%20Data%20Update%3B%0A%09For%20Each%20Row(%0A%09%09dt%2C%0A%09%09dt%3ALot_Wafer%20Label%5B%5D%20%3D%20Substitute(%20dt%3ALot_Wafer%20Label%2C%20%221%22%2C%20%22xxx_%22%20)%0A%09)%3B%0A%09dt%20%26lt%3B%26lt%3B%20End%20Data%20Update%3B%0A)%3B%0A%0Adt_long%3Ddt%20%26lt%3B%26lt%3B%20Concatenate(dt%2Cdt%2Cdt%2Cdt)%3B%0A%0At0%3Dhptime()%3B%0Adt_long%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-724587%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20contare%20il%20numero%20di%20occorrenze%20di%20parole%20specifiche%20in%20una%20stringa%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-724587%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDato%20che%20non%20ricorder%C3%B2%20il%20trucco%20tra%206%20mesi%20e%20non%20voglio%20investire%20tempo%20per%20raccontarlo%20a%20tutti%20i%20colleghi%2C%20ho%20provato%20a%20impostare%20una%20funzione%20personalizzata%3A%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3EAdd%20Custom%20Functions(%0A%09New%20Custom%20Function(%0A%09%09%22test%22%2C%0A%09%09%22countWord%22%2C%0A%09%09Function(%20%7BmyString%2C%20myWord%7D%2C%0A%09%09%09If(%20Length(%20myWord%20)%20%26gt%3B%200%2C%0A%09%09%09%09Return(%20(Length(%20myString%20)%20-%20Length(%20Substitute(%20myString%2C%20myWord%2C%20%22%22%20)%20))%20%2F%20Length(%20myWord%20)%20)%2C%0A%09%09%09%09Return(%200%20)%0A%09%09%09)%0A%09%09)%2C%0A%09%09%26lt%3B%3CDESCRIPTION%3E%3C%2FDESCRIPTION%3E%3CBR%20%2F%3Et0%3Dhptime()%3B%3CBR%20%2F%3Edt_long%20%26lt%3B%26lt%3B%20new%20column(%22new%22%2C%20set%20each%20value(test%3AcountWord(%3ALot_Wafer%20Label%2C%22xxx%22)))%3B%3CBR%20%2F%3EWrite%20(%22via%20custom%20function%3A%5C!t%22%2C(hptime()%20-%20t0)%2F1000000%2C%22s%5C!n%22)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EPurtroppo%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22hogi_0-1708163680692.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22hogi_0-1708163680692.png%22%20style%3D%22width%3A%20310px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F61188iAEF93648BF9A5AB2%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22hogi_0-1708163680692.png%22%20alt%3D%22hogi_0-1708163680692.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3ECome%20devo%20regolare%20la%20funzione%20personalizzata%20per%20renderla%20veloce%20quanto%20la%20versione%20originale%20di%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F3605%22%20target%3D%22_blank%22%3E%40ian_jmp%3C%2FA%3E%20%3F%3CBR%20%2F%3E%20%5Brimuovere%20If(...)%20aiuta%20un%20po'%2C%20ma%20come%20ottenerlo%20%26lt%3B%201s%3F%5D%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
agaddis
Level I

Count number of occurrences of specific words in a string

Hello I'm looking to create a new column in my dataset that counts the number of times a specfic word appears in a string. The words are separated by "*" in each row. 

Example table:

Animal List

1  dog*dog*cat*bird*dog

2  dog*dog*cat*bird*dog*dog

 

 

Output should be

Animal List                                        Dog Count

1  dog*dog*cat*bird*dog                         3

2  dog*dog*cat*bird*dog*dog                  4

 

 

Can provide additional information if needed.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Count number of occurrences of specific words in a string

Here is the formula for counting the number of times "dog" appears in a given column

N Rows( Loc( Words( :Column 1, "*" ), "dog" ) )

agaddis.GIF

Jim

View solution in original post

17 REPLIES 17
txnelson
Super User

Re: Count number of occurrences of specific words in a string

Here is the formula for counting the number of times "dog" appears in a given column

N Rows( Loc( Words( :Column 1, "*" ), "dog" ) )

agaddis.GIF

Jim
agaddis
Level I

Re: Count number of occurrences of specific words in a string

Thank you!!
agaddis
Level I

Re: Count number of occurrences of specific words in a string

 How would this work for wildcard words? For example if dog had dog1 and another said dog2? I still would want it to count all of the dog words. 

txnelson
Super User

Re: Count number of occurrences of specific words in a string

The following formula will find all items with the string "dog" found in it

wordList=words(st,"*");
count=0;for(i=1,i<=n items(wordList),i++,count=sum(count,contains(wordList[i],"dog")));
count;
Jim
l_yampolsky
Level III

Re: Count number of occurrences of specific words in a string

Does the function Loc() exist only in JMP Pro?

Is there a way to count words or specific symbols in a string in regular JMP?

 


@txnelson wrote:

Here is the formula for counting the number of times "dog" appears in a given column

N Rows( Loc( Words( :Column 1, "*" ), "dog" ) )

agaddis.GIF


 

txnelson
Super User

Re: Count number of occurrences of specific words in a string

The documentation for JMP 13 does not indicate the LOC() function is only a JMP Pro function.  I would validate that by running the LOC() function example in the Scripting Index

     Help==>Scripting Index

Names Default To Here( 1 );
Show( Loc( [1 0 1 0 1 0] ) );
Show( Loc( {"A", 2, 3, 2, 5, 2, 4, [1 5]}, 2 ) );
Show(
	Loc( {"A", 2, 3, 2, 5, 2, 4, [1 5]}, [1 5] )
);
Jim
Jeff_Perkinson
Community Manager Community Manager

Re: Count number of occurrences of specific words in a string

I can confirm that the Loc() function is not specific to JMP Pro. It is available in JMP.

-Jeff
KarenHuang
Level I

Re: Count number of occurrences of specific words in a string

Hi

What if there is no delimiter, e.g. I'd like to count how many "1" in a binary string 111001010?

How can I get the results like this?

Capture.JPG

 

Thanks

Craige_Hales
Super User

Re: Count number of occurrences of specific words in a string

Many ways to do this. Here's one.

ASCIIcode = blobtomatrix(chartoblob("1"),"int",1,"big")[1];  // 49
intermediate=blobtomatrix(chartoblob("0101111001010"),"int",1,"big")==ASCIIcode;
// intermediate=[0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0]
sum(intermediate);

Line 1 is just a way to get the ASCII code for the ASCII character "1", returned in a matrix of 1 element.

Line 2 is similar, but gets a bigger array and compares it to the desired code, resulting in the value in the Line 3 comment.

Line 4 just adds up the elements.

 

Craige

Recommended Articles