列ヘッダーの検索と置換こんにちは、
を使用して、列ヘッダー名を正確な名前に置き換えることができます:height << Set Name( "test");
テキストのリストがある場合は、「」に置き換えます。
どうすればそれを進めることができますか?
「名前」「時間」「性別」「身長abc体重」「体重xyz」「12身長テスト」
KATIE 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:列ヘッダーの検索と置換こんにちは、サムさん、
スクリプトに2つの問題が見つかりました。
- 連結「||」を使用しました「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], "" ) )
);
);