열의 행에 항목 목록이 포함되어 있는지 확인하는 공식Mac용 JMP
버전 17.2.0(701896)
다음과 같이 number_number 행이 있는 "Data" 열이 있습니다.
1_3
3_7
6_5
...
이 열을 테스트하여 일부 행에 값 목록의 값이 포함되어 있는지 확인한 다음, 해당 행에 플래그나 레이블을 지정하고 싶습니다.
나는 이와 같은 정교한 공식을 만들 수 있을 거라는 걸 알고 있습니다.
If( :Die X_Y == "3_9" | :Die X_Y == "3_4",
1,
0
)
하지만 긴 다른 값 목록을 검사하는 것은 매우 힘듭니다. 저는 수식에서 검사할 값 목록을 공백이나 쉼표로 구분하여 붙여넣을 수 있기를 원합니다.
" Contains Item " 함수를 찾았습니다. 한 항목에는 잘 작동하지만 도움말 항목에는 "list" 옵션을 구성하는 방법에 대한 통찰력이 없습니다. 다음을 시도했습니다(선택적 구분 기호를 공백으로 지정):
If( Contains Item( :Die X_Y, "3_4 3_9", " " ),
"exclude",
"not exclude"
)
그리고 이것도:
If( Contains Item( :Data, "3_4,3_9", "," ),
"exclude",
"not exclude"
)
기본 구분 기호가 쉼표라는 것을 알고 있지만 작동하는 모든 것을 찾도록 강제하고 싶었습니다. 어느 쪽도 항목 포함 함수가 찾는 동작(일치하는 경우 논리적 1, 일치하지 않는 경우 0)을 반환하지 않습니다. 사용할 수 있는 더 나은 함수가 있으면 알려주세요.
제가 풀고 싶은 일반화된 문제는 열을 검사하여 긴 항목 목록과 일치하는 항목을 찾는 것입니다.
감사해요
자동화 및 스크립팅맥 OSRe: 항목 목록 중 열의 행에 항목이 포함되어 있는지 확인하는 수식좋은 부작용:
이 토론을 통해 저는 다음과 같은 생각을 하게 되었습니다.
Contains는 콜.. 집계 속도도 증가시키나요?
믿으실지 말지 몰라도, 그렇습니다. 와, 그렇습니다!!!!
https://community.jmp.com/t5/Discussions/How-do-I-use-the-Col-Maximum-Formula-with-a-quot-where-quot/mp/810363/highlight/true#M99287
캐릭터 비교가 왜 이렇게 느린지 아시나요?
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식읽기는 다음과 같습니다: 3개의 인수
- x - 문자열
- 3가지 옵션:
- 검색할 항목
- 여러 항목 목록 - hem 중 하나가 일치합니까?
- 검색할 패턴 - 선택 인수: x를 단어로 분할할 구분 기호
@datanaut 님이 쓰셨습니다:
따라서 (제가 단순하게 해석한 바에 따르면) x 또는 {list}에는 검색할 단어가 들어 있거나 비교할 단어 목록이 들어 있을 수 있습니다.
-> 네.
Jarmo의 예와 같이 열이 포함됨
열 수식의 경우 이는 항상 가능합니다. 아이디어는 다음과 같습니다.
각 행에 대해 JMP는 자동으로 해당 행의 열 항목을 가져옵니다.
수식 편집기를 사용하면 항상 이 작업을 수행하게 됩니다. 알아차리지 못한 채 말이죠.
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식@jthi , @txnelson , @hogi , @mmarchandFSLR , 제 질문에 답변해 주시고 노력해 주셔서 감사합니다.
Jarmo가 내 문제를 찾아냈습니다 -- 내 공식에서 목록과 항목을 바꾸는 것. 올바른 사용법을 보여주는 코드에 감사드립니다.
re: "문서가 약간 부족합니다"
저도 동의합니다. 스크립팅 인덱스의 지침과 예는 제게는 약간 모호해 보입니다. 스크립팅 인덱스의 항목은 다음과 같습니다.
"
항목이 포함되어 있습니다(x, <목| {목록} |무늬>, <구분 기호>)
...
Returns a Boolean that indicates whether the word (목), one of a list of words (목록), or pattern (무늬) matches one of the words in the text represented by x. Words are delimited by the characters in the optional quoted delimiter (구분 기호) string. A comma is the default delimiter. Blanks are trimmed from the ends of each extracted word from the input text string (x).
"
그래서 (내 단순한 독해에 따르면) x 또는 {list}는 검색할 단어나 비교할 단어 목록을 포함할 수 있습니다. Jarmo의 예에서처럼 Column을 포함하는 몇 가지 대안을 보여주는 몇 가지 예가 더 있으면 명확히 하는 데 도움이 될 수 있습니다.
저는 이미 해결책을 사용했어요! 다시 한번 감사합니다.
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식아, 좋죠!
처음에는 Where()를 사용하는 데에 꽤 나쁜 경험이 있었습니다. 하지만 왜 그런지는 기억나지 않습니다.
아마 제가 잘못된 구문을 사용했을 수도 있고, 아니면 그 사이에 문제가 해결되었을 수도 있습니다 ...
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식Where() 함수가 <보다 훨씬 빠르다는 점을 덧붙이는 것이 가치가 있다고 생각합니다. <<> 이름은 Here(1); dt = Data Table("SATByYear"); Show(N Rows(dt)); //N Rows(dt) = 21245376; now = HP Time(); dt << Select Where( :State == "Wisconsin" | :State == "Alabama" ); Wait(0); total = HP Time() - now; Print("<
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식죄송합니다. 이전 실행에서 wait()를 놓쳤습니다. 이는 답변 1을 반전시키고 #3, #4 및 #5에 대한 새로운 가능성을 제시합니다.
새로운 발견:
- item()을 포함합니다 @jthi 의 구문을 사용하면 더 빠르고 v2는 더 느립니다.
- 선택 where()이것을 대체하면 훨씬 더 빨라집니다.행을 가져옵니다. () + 행을 선택합니다.
- 문자열 비교를 contains item() 으로 바꾸면 Select Where()가 상당히 더 빨라집니다(!!).
- (2)와 (3)을 결합하는 것은 매우 유사하다
- ... 더 큰 데이터 세트에도 적용됩니다.

더 보기...
names default to here(1);
dt = Open( "$SAMPLE_DATA/Wafer Stacked.jmp" );
New Column( "x_y",
Character,
Formula( Concat Items( {Char( :X_Die ), Char( :Y_Die )}, "_" ) )
);
wait(0);
t0=hptime();
New Column( "contains item",
Character,
Formula( If( Contains Item( "1_3 3_9", :x_y, " " ), "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("formula - contains item", t);
t0=hptime();
New Column( "contains item v2",
Character,
Formula( If( Contains Item( :x_y, {"3_1","4_4"}) , "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("1) formula - contains item v2", t);
t0=hptime();
New Column( "get rows where",
Character,
set each value("not excluded") );
myrows=[];
for each( {compare}, {"3_1","4_4"},
myrows = V concat to (myrows, dt << get rows where(:x_y == compare));
);
dt << select rows(myrows); // just for fun - it's fast
dt[myrows,"get rows where"] = Repeat({"excluded"},n items(myrows) );
t= (hptime()-t0)/1000000;
print("2) get rows where", t);
t0=hptime();
for each( {compare}, {"3_1","4_4"},
dt<<SELECT where=""> names default to here(1);
dt = Open( "$SAMPLE_DATA/Wafer Stacked.jmp" );
New Column( "x_y",
Character,
Formula( Concat Items( {Char( :X_Die ), Char( :Y_Die )}, "_" ) )
);
wait(0);
t0=hptime();
New Column( "contains item",
Character,
Formula( If( Contains Item( "1_3 3_9", :x_y, " " ), "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("formula - contains item", t);
t0=hptime();
New Column( "contains item v2",
Character,
Formula( If( Contains Item( :x_y, {"3_1","4_4"}) , "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("1) formula - contains item v2", t);
t0=hptime();
New Column( "get rows where",
Character,
set each value("not excluded") );
myrows=[];
for each( {compare}, {"3_1","4_4"},
myrows = V concat to (myrows, dt << get rows where(:x_y == compare));
);
dt << select rows(myrows); // just for fun - it's fast
dt[myrows,"get rows where"] = Repeat({"excluded"},n items(myrows) );
t= (hptime()-t0)/1000000;
print("2) get rows where", t);
t0=hptime();
for each( {compare}, {"3_1","4_4"},
dt<</SELECT> <SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1731305493836.png" style="width: 400px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="hogi_0-1731305493836.png" style="width: 400px;"><span class="lia-inline-image-display-wrapper" image-alt="hogi_0-1731305493836.png" style="width: 400px;"><img src="https://us.v-cdn.net/6038925/uploads/images/70019i116F7A07829AD82B/hogi_0-1731305493836.png" role="button" title="hogi_0-1731305493836.png" alt="hogi_0-1731305493836.png" /></span></SPAN></SPAN>
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식팁과 요령 - JMP/JSL을 사용한 모범 사례 에 추가했습니다.
#4는 놀랍습니다. 지금 당장은 이렇게 말하고 싶습니다.

Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식댓글 감사합니다.
더 깊이 파헤쳐보면 - 실제로는 포함 항목 과 선택 위치가 다릅니다.
몇 가지 발견 사항:
- Contains item() 은 역 "v2" 구문을 사용하면 더 빠릅니다.
- 선택 where()이것을 대체하면 훨씬 더 빨라집니다.행을 가져옵니다. () + 행을 선택합니다.
- Select Where()는 문자열 비교를 contains item() 으로 대체하여 상당히 빨라졌습니다.
- 그리고 (2)와 (3)을 결합하면 (2)보다 ... 배 더 느려집니다(?!?!)
- 따라서 이 데이터 세트에 대한 승자는 #2입니다.
총:

세부:
더 보기...names default to here(1);
dt = Open( "$SAMPLE_DATA/Wafer Stacked.jmp" );
New Column( "x_y",
Character,
Formula( Concat Items( {Char( :X_Die ), Char( :Y_Die )}, "_" ) )
);
t0=hptime();
New Column( "contains item",
Character,
Formula( If( Contains Item( "1_3 3_9", :x_y, " " ), "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("formula - contains item", t);
t0=hptime();
New Column( "contains item v2",
Character,
Formula( If( Contains Item( :x_y, {"3_1","4_4"}) , "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("1) formula - contains item v2", t);
t0=hptime();
New Column( "get rows where",
Character,
set each value("not excluded") );
myrows=[];
for each( {compare}, {"3_1","4_4"},
myrows = V concat to (myrows, dt << get rows where(:x_y == compare));
);
dt << select rows(myrows); // just for fun - it's fast
dt[myrows,"get rows where"] = Repeat({"excluded"},n items(myrows) );
t= (hptime()-t0)/1000000;
print("2) get rows where", t);
t0=hptime();
for each( {compare}, {"3_1","4_4"},
dt<<SELECT where="">names default to here(1);
dt = Open( "$SAMPLE_DATA/Wafer Stacked.jmp" );
New Column( "x_y",
Character,
Formula( Concat Items( {Char( :X_Die ), Char( :Y_Die )}, "_" ) )
);
t0=hptime();
New Column( "contains item",
Character,
Formula( If( Contains Item( "1_3 3_9", :x_y, " " ), "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("formula - contains item", t);
t0=hptime();
New Column( "contains item v2",
Character,
Formula( If( Contains Item( :x_y, {"3_1","4_4"}) , "exclude", "not exclude" ) )
);
dt << run formulas();
t= (hptime()-t0)/1000000;
print("1) formula - contains item v2", t);
t0=hptime();
New Column( "get rows where",
Character,
set each value("not excluded") );
myrows=[];
for each( {compare}, {"3_1","4_4"},
myrows = V concat to (myrows, dt << get rows where(:x_y == compare));
);
dt << select rows(myrows); // just for fun - it's fast
dt[myrows,"get rows where"] = Repeat({"excluded"},n items(myrows) );
t= (hptime()-t0)/1000000;
print("2) get rows where", t);
t0=hptime();
for each( {compare}, {"3_1","4_4"},
dt<</SELECT>
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식저는 Jarmo의 솔루션과 제 솔루션을 비교하는 몇 가지 타이밍 테스트를 했는데, Contains Item 솔루션이 Select Where 솔루션보다 엄청나게 빠르다는 것을 알았습니다.
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식Usually in cases like this I tend to use Words() to split the string into a list and then compare using Contains() (or in some rare cases Contains Item()). But Contains Item() should also work and you just seem to have your parameters in incorrect order</CODE></P>
<PRE><CODE class=" language-jsl">New Table("Untitled",
Add Rows(3),
Compress File When Saved(1),
New Column("Column 1", Character, "Nominal", Set Values({"1_3", "3_7", "6_5"})),
New Column("Column 2",
Character,
"Nominal",
Formula(
If(Contains Item("1_3 3_9", :Column 1, " "),
"exclude",
"not exclude"
)
),
Set Selected
)
)

Scripting Index의 두 번째 예


또는 JSL 구문 참조에는 다소 모호한 예가 있습니다. https://www.jmp.com/support/help/en/18.0/#page/jmp/character-functions-2.shtml?os=win&source=application#ww6166335 하지만 설명서가 약간 부족합니다.
Re: 항목 목록 중 하나라도 열의 행에 포함되어 있는지 확인하는 공식내가 취할 접근 방식은 다음과 같습니다.
names default to here(1);
dt=current data table();
dt << clear select;
find = {"3_1","4_4"};
for each( {compare}, find,
dt<<SELECT where="">
Once the rows are selected, then excluding, deleting etc. can be done.</SELECT>