열 머리글 검색 및 바꾸기안녕,
다음을 사용하여 열 머리글 이름을 정확한 이름으로 바꿀 수 있습니다. : height << Set Name ( "test");
텍스트 목록이 있으면 ""로 바꾸고 싶습니다.
어떻게 진행합니까?
"이름" "시간" "성별" "신장 abc 체중" "체중 xyz" "12 신장 테스트"
케이티 12 F 59 95 59
루이즈 12F 61123 61
최종 출력 :
"이름" "시간" "섹스" "abc" "xyz" "12 테스트"
Names Default To Here( 1 );
dt = Open( "C:/JSL/BigClass.jmp" );
headerList = dt << get column names( string );
//:height << Set Name( "test" );
For( i = 1, i <= N Items( headerList ), i++,
If( (headerList[i] == "height" || headerList[i] == "weight"), //trying to find any column header has height or weight and replace with ""
Column( dt, colList[i] ) << set name( " " ) //above are just two examples, maybe put it in list and loop?
)
);
스크립팅Re : 열 머리글 검색 및 바꾸기안녕 샘,
스크립트에서 두 가지 문제를 발견했습니다.
- 연결 "||"을 사용했습니다. "Or"문을 나타내는 코드 ( "|"여야 함)
- JMP에서는 열 이름을 ""로 지정할 수 없습니다.
또한 일반적으로 열 이름 목록을 반복하는 대신 번호로 열을 호출하는 것이 더 빠르고 쉽습니다.
그래서 여기에 내가 생각 해낸 것이 있습니다.
Names Default To Here( 1 );
dt = Open( "C:\Program Files\SAS\JMP\14\Samples\Data\Big Class.jmp" );
headerList = dt << get column names( string );
For( i = 1, i <= N Items( headerList ), i++,
If( (headerList[i] == "height" | headerList[i] == "weight"), //Fixed the "Or" statement
Column( dt, i ) << set name(substitute (headerList [i], "e", "x")) //Used the substitute function as an example, you can replace any string with ""?
)
);
Re : 열 머리글 검색 및 바꾸기미리 목록을 정의하고 이중 중첩 루프를 수행하려고했습니다. 그것은 단지 대체 stringReplace [3].
headerList = dt << get column names( string );
stringReplace = List();
stringReplace[1] = "height";
stringReplace[2] = "e";
stringReplace[3] = "a";
For( i = 1, i <= N Items( headerList ), i++,
For( j = 1, j <= N Items( stringReplace ), j++,
Column( dt, i ) << set name( Substitute(headerList[i], stringReplace[j], "" ) )
);
);