조건에서 원하는 행을 설명하기 위해 'Contain'을 사용해야 하는 경우 Select Where 사용<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />안녕하세요, 저는 이 간단한 쿼리 조각으로 잡습니다. 저는 JSL에서 여러 다른 문자열 조각을 포함하는 일부 행을 선택하기를 원합니다. 마찬가지로 열에는 '1. 혈액 샘플' '2. 혈액 샘플', 1. 혈청 샘플' 등 하나의 조건식에서 다음과 같이 작성하고 싶습니다.
dt >> select where('샘플 이름이 있는 열' 포함 '혈액' 또는 '혈청').
좋은 오래된 SAS를 참조하여 다음과 같이 작성합니다.
데이터 새 집합;
오래된 세트를 설정;
where(index('컬럼','혈액')>=1 또는 index('컬럼','혈청')>=1);
운영;
JSL에서 이를 수행하는 방법은 무엇입니까?
안부 Poul
Re: 원하는 행을 설명하기 위해 'Contain'을 사용해야 하는 조건에서 Select Where 사용흠 더 많은 민속.스크립팅 안내서에 이 구문에 대한 힌트가 있지만 이렇게 명확한 내용은 없습니다.MS 감사합니다!
Re: 원하는 행을 설명하기 위해 'Contain'을 사용해야 하는 조건에서 Select Where 사용아래 코드는 Column()과 As Column()의 차이점에 대한 이해를 요약하려는 시도입니다.
//PMroz example table
dt=New Table( "Search Example",
Add Rows( 6 ),
New Column( "Sample Means",
Character,
Set Values(
{"1. blood sample", "2. blood sample", "1. serum sample",
"2. serum sample", "1. cardio sample", "2. cardio sample"}
)
)
);
// Column("X") returns a column reference.
// As Column("X") is equivalent to :X, giving access to the values of Column("X").
// Without an index, :X returns the value of the current row.
//
Row() = 3;
x = As Column( dt, "Sample Means" );
y = dt:Sample Means;
col = Column( dt, "Sample Means" );
Show( x, y, col );
// However, with an index (e.g. :X and Column("X")) both the current row
//and the column reference is bypassed; and both commands yield the same result.
x = dt:Sample Means[1];
y = Column( dt, "Sample Means" )[1];
Show( x, y );
// Hence, the below messages using As Column() Or Column()[] are equivalent.
// The empty square brackets ensures that "Select Where" loops through the value of each row.
//Without them, it would repeatedly look for a string in a column reference which would fail every time.
dt << select where(
Contains( Column( dt, "Sample Means" )[], "blood" ) |
Contains( Column( dt, "Sample Means" )[], "serum" )
);
dt << select where(
Contains( As Column( dt, "Sample Means" ), "blood" ) |
Contains( As Column( dt, "Sample Means" ), "serum" )
);
Re: 원하는 행을 설명하기 위해 'Contain'을 사용해야 하는 조건에서 Select Where 사용나는 얼마 전에 이 토론 포럼에서 "as column" 구문을 얻었다고 생각합니다.약간 민중적이야 - 그냥 말해 column(dt, "colname") 이 컨텍스트에서는 작동하지 않지만 열로 일했다.
다른 사람이 이유를 설명할 수 있습니까? 열로 필요합니까?
Re: 원하는 행을 설명하기 위해 'Contain'을 사용해야 하는 조건에서 Select Where 사용안녕하세요, 답변이 정확하고 제가 원하는 것을 할 수 있도록 도와줍니다. 학습 측면에서 'as 열'이 있는 이유를 설명할 수 있습니까? '포함'이 열에서만 작동하기 때문인가요? 그리고 '열로'는 올바른 데이터 유형을 반환합니까?
나는 이것을 이해하는 데 약간의 문제가 있습니다.
문안 인사
폴
Re: 원하는 행을 설명하기 위해 'Contain'을 사용해야 하는 조건에서 Select Where 사용거의 다 왔습니다.다음 코드를 스크립트 창에 복사하고 실행합니다.
New Table( "Search Example",
Add Rows( 6 ),
New Column( "Sample Means",
Character,
Nominal,
Set Values(
{"1. blood sample", "2. blood sample", "1. serum sample",
"2. serum sample", "1. cardio sample", "2. cardio sample"}
)
)
);
dt = current data table();
dt << select where (contains(as column(dt, "Sample Means"), "blood") |
contains(as column(dt, "Sample Means"), "serum"));